Conversion from string “” to type Long is not valid

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Conversion from string “” to type Long is not valid



How can I fix this error? I am updating this code from VB.06 to vb.net everything is working correctly except this line. And it is happening only when the order number is wrong



enter image description here




2 Answers
2



it depends on how you like to handle the error.
you can wrap the line with


if txtOrderQty.text <> "" then

end if



and let the code to continue.



or you can issue a warning message before processing further.



The string "" can not be converted to Long because it is not a number.


""


Long



You can use TryParse to convert the string to Long. If it can not be parsed then 0 is returned into the variable in the second argument (orderQty):


TryParse


Long


0


orderQty


Dim orderQty As Long
Long.TryParse("", orderQty)
lblToBeScanned1.Text = (orderQty - lngUPC1).ToString()





Thank you,Let me try
– Doll
1 min ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name