Как в VB переводить числа из десятичных в НЕХ?
Формулировка задачи:
Как в VB переводить числа из десятичных в НЕХ
и наоборот
из НЕХ в десятичное значение
Спасибо !
Решение задачи: «Как в VB переводить числа из десятичных в НЕХ?»
textual
Листинг программы
Private Sub Command1_Click() ' Command1.Caption = DEC
Text2.Text = ''
On Error Resume Next
If Trim(Text1.Text) <> '' Then Text2.Text = Val('&H' & Text1.Text & '&')
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Command2_Click() ' Command1.Caption = HEX
Text1.Text = ''
On Error Resume Next
If Trim(Text2.Text) <> '' Then Text1.Text = Hex(Text2.Text)
Text2.SelStart = Len(Text2.Text)
End Sub
Private Sub Form_Load()
'Dim k, l
'k = Hex(4500) '=2D
'l = Val('&H1194') ' = 45
Text1.Text = '2D'
Text2.Text = '45'
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Text1.Text = UCase(Text1.Text)
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
Text2.Text = UCase(Text2.Text)
Text2.SelStart = Len(Text2.Text)
End Sub