I’m working on a simple chat client to practice network programming w/ VC++ .NET. I have a yahoo messenger login example for the latest protocol (YMSG12) written in VB 6 and I’m converting everything over to VC++. Below are two functions for converting ASCII to HEX and vise versa. These helper functions are used when constructing the login packets. I’m not sure if these two functions can be converted to VC++. For instance “DoEvents” and “UBound”, I have no idea how to convert this, and I could not find anything on google.
Code:Public Function ChrH(strString) As String 'hex to ascii Dim A1 A1 = Split(strString, " ") Dim i As Integer For i = 0 To UBound(A1) ChrH = ChrH & Chr("&H" & A1(i)) DoEvents Next i End Function
Code:Public Function AscToHex(strString As String) As String 'ascii to hex Dim i As Integer For i = 1 To Len(strString) If Len(Hex(Asc(Mid(strString, i, 1)))) = 1 Then AscToHex = AscToHex & "0" & Hex(Asc(Mid(strString, i, 1))) Else AscToHex = AscToHex & Hex(Asc(Mid(strString, i, 1))) End If If i <> Len(strString) Then AscToHex = AscToHex & " " DoEvents Next i End Function