How to display the numeric numbers - vb.net

Here's the content of my DataGrid
id
1
2
3A
4
5
6A
..
...
10V1
I want to get the max number from the datagrid. Then, I want to
display the next number (In this case: 11) in the textbox beside the grid
Expected Output
id
1
2
3A
4
5
6A
..
...
10V1
11
I tried the following code:
textbox1.text = gridList.Rows(gridlist.RowCount() - 1).Cells(1).Value + 1
It works if the previous row values is entirely numeric. However, if the value is alpahnumeric, I am getting the following error:
Conversion from string "10V1" to type 'Double' is not valid.
Can someone help me solve this problem? I am looking for a solution in VB.Net

You may want to look into Regex to do that (based on what I understand from your question)
Here's a related question on this.
Regex.Match will return the part of the string that will match the expression... In your case, you want the first number in your string (Try "^\d+" as your expression, it will find any serie of numbers at the beginning of your string). You can then convert the result string into an int and add 1 to it.
Hope this helps!
Edit: Here's more info on regex expressions.

Related

Try to check if column consists out of 3 numbers, and change the value to the first number of the column

I'm trying to create a new column called 'team'. In the image below you see different type of codes. The first number of the code is the team someone's in, IF the number consists out of 3 characters. E.G: 315 = team 3, 240 = team 2, and 3300 = NULL.
In the image below you can see my data flow so far and the expression I have tried, but doesn't work.
You forget parenthesis () in your regex :
Try :
^([0-9]{3})$
Demo

Pandas Python How to handle question mark that appeared in dataframe

I have these question marks that appeared in my data frame just next to numbers and I dont know how to erase or or replace them. I dont want to drop the whole row since it may result in inaccurate results.
. Value
0 58
1 82
2 69
3 48
4 8
I agree with the comments above that you should look into how you imported the data. But here is the answer to your question of how to remove the non numeric characters:
This will remove the non numeric characters
df['Value'] = df['Value'].str.extract('(\d+)')
Then if you wish to change the datatype to in you can use this:
df['Value'] = pd.to_numeric(df['Value'])

Pandas dataframe selection df['a'][50][:51]

I have a dataframe where one of the column name is 'a'
I came across a following selection expression
dataframe['a'][50][:50]
I understand dataframe['a'][50] selects the row 49 in column ['a'], but what does [:50] do?
Thank you
If dataframe['a'][50][:50] doesn't error out and it actually returns something, it means the row 49 in column ['a'] contains iterables(more precisely sequence types) such as list, string, tuple...
dataframe['a'][50][:50] returns the sequence from element 0 to 49 from the value of the row 49 in column ['a'].
As I said above, if the row 49 in column ['a'] doesn't contain a sequence type, you will get errors. Try check dataframe['a'][50] to see if it is a sequence type
Note: dataframe['a'][50] is chain-indexing. It is not recommended. However, it is out of the scope of this question so I don't go into the detail of it.

How to get the last number of a string using selenium webdriver

1 - 2 of 2
Above is my text. This is from paging of a web application. How do i extract the last number of the above text. SO i will get the count of list in that page and i can run a loop with respect to the number.
You can use substring
Let's consider your example. You have a String 1 - 2 of 2 (pagination probably)
Each of individual character is a specified index of a String
1 = 0
space = 1
- = 2
space = 3
etc.
String has a set of methods to perform various tasks. One of them is length() which gives you number of characters in your String
What you can do is to pass your length of String to substring.
Example:
myString.substring(0,1) will give you results of 1
myString.substring(0,myString.length()) wil give you results of 1 - 2 of 5
Additional info: myString.length() is an int type so you can perform math operations like + or -
myString.substring(0,myString.length()-1) will give you results of 1 - 2 of
I gave you the tools, now it's time for you to find the solutions.
You could just split the string using the spaces and then grab the last element of the split array. That should cover you even if the last number has more than one digit. Throw in a trim, just in case, to remove any leading/trailing white space.
String[] splitter = pageCount.trim().split(" ");
System.out.println(splitter[splitter.length - 1]);

exclude data having specific value [substring within a string] using pentaho

I have a column "Number field" (Excel sheet). It has value as shown below.
Test_Number Number_field
1 0011 10 00A34 PS
2 0011 10 00A34 PS
3 0010 01 00A30 PS
4 0010 01 00A30 PS
5 0010 01 00A35 PS
6 0010 01 00A35 PS
Now, from these i need to remove those which contains "0A34" and "0A35". How can i achieve this? I tried "filter" option, but I cannot search substring in a string using this. Please help
You can simply do this in two steps as follows.
In Filter rows step you add the following conditions.
Use combination of User Defined Java Expression step with following parameters:
Java expression: (Number_field.indexOf("0A34") != -1 || Number_field.indexOf("0A35") != -1) ? "Remove" : "Ok"
Value type: String
New field: is_row_to_remove
and Filter rows step with this parameters:
The condition: `is_row_to_remove = Remove (String)
Send 'true' data to step: Your next step
Send 'false' data to step: Dummy (do nothing) step
Flow explanation:
User Defined Java Expression: Java code finds 0A34 or 0A35 and marks such a row with Remove value in a new field is_row_to_remove
Filter rows: The step filters record stream according to value in is_row_to_remove. If value is set to Remove then continues with Dummy step. Otherwise continues to your next step.
If you want to do that in excel itself then you can use below formula and have filter on that to remove the records from your excel.
Add below formula and drag it upto your all records. Create filter on this new formula column and then remove the records.
=IF(OR(IFERROR( SEARCH("A34",B2), 0),IFERROR( SEARCH("A35",B2), 0)), "REMOVE", "KEEP")
check snap below.
Hope this will help you.
If it helps then mark it as answer.