question about vb6.0..data type conversion
-
i want to convert string into byte....this can be done in vb.net..can somebody help me in doing this in vb6.0..here the simple code.. Private Sub Form_Load() Dim str1 As String Dim i As Byte i = CByte(Val(str1)) Text1.Text = i End Sub but this code still not able to convert string into byte....and still giving type mismatch error....i m unable to solve this small problem farah farah
-
i want to convert string into byte....this can be done in vb.net..can somebody help me in doing this in vb6.0..here the simple code.. Private Sub Form_Load() Dim str1 As String Dim i As Byte i = CByte(Val(str1)) Text1.Text = i End Sub but this code still not able to convert string into byte....and still giving type mismatch error....i m unable to solve this small problem farah farah
Which line gives the error?
farah mazhar wrote:
Text1.Text = i
Perhaps the problem is: Text1.Text (String Datatype) = i (Byte Datatype) MisMatch... Not sure why you convert Integer to string, and then back to string for the Textbox? This may be of interest (but its vb.Net so not sure about VB6): Convert a decimal value to binary, octal, or hexadecimal The ToString method of the Convert class lets you easily and quickly convert a decimal value into a string representation of that number to binary, octal, or hexadecimal base:
' convert to binary Convert.ToString(11, 2)) ' => 1011 ' convert to octal Convert.ToString(123, 8)) ' => 173 ' convert to hexadecimal Convert.ToString(254, 16)) ' => fe
The ToString method is overloaded to take a Byte, a Short, an Integer, or a Long value in the first argument; the second argument can only be 2, 8, 10, or 16, else an exception will be thrown -- modified at 6:18 Thursday 8th November, 2007 -
i want to convert string into byte....this can be done in vb.net..can somebody help me in doing this in vb6.0..here the simple code.. Private Sub Form_Load() Dim str1 As String Dim i As Byte i = CByte(Val(str1)) Text1.Text = i End Sub but this code still not able to convert string into byte....and still giving type mismatch error....i m unable to solve this small problem farah farah
thanx for ur help but i need the code in vb6.0....can anyone help me for this...i need this for my project....thanx in advance farah
-
thanx for ur help but i need the code in vb6.0....can anyone help me for this...i need this for my project....thanx in advance farah