Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My project is developed in vb.net.I've used Msh FlexGrid and i want to check If Grid Cell Has any value in grid.

What I have tried:

My code is
<pre>  
With GridMed
          For intRow = 1 To .Rows - 1
                    If Not .TextMatrix(intRow, .GetColIndex("HpName")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("DoctorName")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("RegNo")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("ID1")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Id2")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Fitness")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("CertifiedDate")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Status")) Then
                        Exit For
                    End If
End with
                   
It shows Following error 

Conversion from string "hjkhj" to type 'Long' is not valid.
Posted
Updated 1-Oct-18 0:50am
v3

1 solution

Look at the error message:
Conversion from string "hjkhj" to type 'Long' is not valid.
It's pretty clear, and absolutely right.
What kind of number do you expect to get from the string "hjkhj"? The system is telling you "this isn't a number, I can't do anything with it".

You need to check your data source, and find out why what you expect to be a numeric value is a string that looks like lazy typing...

We can't do that for you.
 
Share this answer
 
Comments
[no name] 1-Oct-18 7:32am    
Thank you sir.I want to check if grid has any value in grid cell..I tried following code but it Does not working.How to check each cell contains value or not
  
With GridMed
          For intRow = 1 To .Rows - 1
                    If Not .TextMatrix(intRow, .GetColIndex("HpName")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("DoctorName")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("RegNo")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("ID1")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Id2")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Fitness")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("CertifiedDate")) <> "" Or Not .TextMatrix(intRow, .GetColIndex("Status")) Then
                        Exit For
                    End If
End with
OriginalGriff 1-Oct-18 7:55am    
Use the debugger!
[no name] 1-Oct-18 7:57am    
I already check it.But it does not working.sir i want check if any one field has value If Condition is Comes to end but it not comes
OriginalGriff 1-Oct-18 8:09am    
And how - exactly - did you check it with the debugger?
What - exactly - did it show you?
[no name] 1-Oct-18 8:19am    
My grid has five fields and 3 fields have Value now i want to End the If statement but it Control Goes to Exit For statement what is the Mistake i done

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900