Hi ,

I have three text boxes (Text1.text,Text2.text,Text3.text) in which i will enter a decimal value in text1.text . When i click the command button i want the Binary value in text2.text (i.e Text box 2)and Hex value in Text3.text (i.e Text box 3.)Private Sub Command1_Click()

Text2.Text = Dec2Bin(Text1.Text)

Text3.Text = Bin2Hex(Text2.Text)

End SubDec2Bin and Bin2Hex are Excel commands, the same i tried in VB 6.0 but its not working ..please help out

Use the HEX$ function for the hex conversion. Its input is a decimal value and it outputs a text string. So you would need to convert the text1.text into an integer value and provide that as the parameter to the HEX$ function: Text2.Text = HEX$(text1_value)

To convert to Binary, set up a table to convert each hex "digit" to its binary equivalent. See partial table below:

Hex F = Binary "1111"

Hex A = Binary "1010"

Hex 7 = Binary "0111"Dan

Ask Your Question

Weekly Poll