|
-
Jul 31st, 2004, 09:55 AM
#1
Thread Starter
New Member
How to convert String to Long or Int??
Hi,
Can't really convert string to long.. or int.. Pls enlighten me?
thanks...
'Serial Number is number value in access database
Dim StockVerification As New OleDbCommand("SELECT serial_number from stock where serial_number = '" + txbRentalSerial.Text + "'", cnnRental)
'will prompt 'data mismatch' when executing the program
Tried using below and cant also...
Dim mylong As Long
Dim s As String
'mylongl = CLng(txbRentalSerial.Text)
'mylong = System.Convert.ToInt64(txbRentalSerial.Text())
-
Jul 31st, 2004, 10:05 AM
#2
Junior Member
Dim mylong As Long
mylong = CLng(txtRentalSerial.Text)
MsgBox(mylong.ToString())
That works.... you had some typos in the code you posted. I don't know if that was copied and pasted from your project, if so, that could be your problem. This worked fine for numeric values I entered into the textbox txtRentalSerial.
Chris
-
Jul 31st, 2004, 10:17 AM
#3
Frenzied Member
Although valid, your code will produce an error balmerch if the user has typed a non-numeric character in the text box.
You will need to either wrap the code in a TryCatch, or use th Val function on the contents of the text box.
~Peter

-
Jul 31st, 2004, 10:18 AM
#4
Thread Starter
New Member
Thanks Chris...
What is the difference between msgbox() and messagebox.show()
i used messagebox.show() will encounter this error...
"Option string On disallow implicit conversion from long to string"
Now tat i can conver to mylong... how do i pass it into the txbrentalserial.text..?
Dim StockVerification As New OleDbCommand("SELECT serial_number from stock where serial_number = '" + txbRentalSerial.Text + "'", cnnRental)
-
Jul 31st, 2004, 12:19 PM
#5
Sleep mode
Use either :
1-The static method [ Convert.ToXXX )
or
2-Long.Parse (xxxx)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|