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

amby

Can you be more explicit as to what your ultimately trying to do?

What 'string' are you trying to convert....can you give example?

Just curious but why do you want to convert the string?

Try this and tell me what happens. If bad stuff, revert to above questions and reply.

' add the Asc to conversion
i = CByte(Asc(str1))
' ok?

thanx themaj thanx alot!!
the syntax u provided gave same result which i want......sorry for late replying....i m checking my mail after a long time.......anywez thanx again for ur help..

Amby,

Glad I could help.
In the future you may want to explain more of your issue so that others may have the opportunity to learn more as well.

My explanation, while it worked for you may not always be the best practice so the more info you present, the more others might chime in with other options. We're all about learning more here and sharing concept and ideas. Someone also may add more information that would help and others.

If this is resolved; please makr it as so.

Happy coding,

themaj

Dim company As String
Dim b() As Byte

company = "CHILKAT SOFTWARE"

b = StrConv(company,vbFromUnicode)
commented: 3 years late, and wrong, too. Really good start, bucko. -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.