Convert Hexadecimal to ASCII

0 comments

Posted on 23rd March 2011 by Admin in String Manipulation |System API |Visual Basic 6

Visual Basic 6 function that will convert the Hexadecimal value into ASCII value. Please copy the code below to module area and call the function name hexToascii like sample below.



command1_click

Text1.Text = hexToascii(Text2.Text)

End Sub


Public Function hexToascii(ByVal hextext As String) As String
For x = 1 To Len(hextext)
num = Mid(hextext, x, 2)
Value = Value & Chr(Val("&h" & num))
x = x + 1
Next x


hexToascii = Value
End Function

How to use Message Box

0 comments

Posted on 15th April 2010 by Kenneth in System API |Visual Basic 6

, , ,

‘This tutorial pop-up a message to user to confirm. Here’s the code

Private Sub Command1_Click()
Dim myValue As String
myValue = MsgBox(“Are your sure you want to delete this file?”, vbQuestion + vbYesNo, “Confirm Delete”)
If myValue = vbNo Then Exit Sub ‘ Do nothing
‘—- Do some codes here to delete record in database

End Sub

Parameters

Prompt
Required.String expression displayed as the message in the dialog box. The maximum length ofPromptis approximately 1024 characters, depending on the width of the characters used. IfPromptconsists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a line feed character (Chr(10)), or a carriage return/linefeed character combination (Chr(13) &Chr(10)) between each line.

Buttons
Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If you omitButtons, the default value is zero.

Title
Optional.String expression displayed in the title bar of the dialog box. If you omitTitle, the application name is placed in the title bar.