Dim i As Long Dim v As Variant Dim vSrc As Variant Dim vDest() As Variant Dim MyLen As Integer
vSrc = Split(Text1.Text, vbCrLf)
For Each v In vSrc
If IsNumeric(v) Then
ReDim Preserve vDest(i) vDest(i) = Hex(v)
i = i + 1
End If
Next MyLen = Len(Join(vDest, vbCrLf)) If MyLen Mod 2 = 0 Then Text2.Text = Join(vDest, vbCrLf) Else Text2.Text = "0" & Join(vDest, vbCrLf) End If End Sub
Private Sub Command1_Click() Dim a As Long Dim b As String a = Val(Text1) b = Hex(a) If Len(b) Mod 2 = 0 Then b = b Else b = "0" & b End If Text2 = b End SubPrivate Sub Form_Load() Text1 = "" Text2 = "" End Sub
CONGCONG1105的程序还是奇数输出,并没有实现偶数输出 zdingyun的程序运行直接报错
先在窗体上建立一个Button 两个Text Private Sub Command1_Click() Dim a As Long Dim b As String a = Val(Text1) b = Hex(a) If Len(b) Mod 2 = 0 Then b = b Else b = "0 " & b End If Text2.Text = b End SubPrivate Sub Form_Load() Text1.Text = " " Text2.Text = " " End Sub
Private Sub Command1_Click()
Dim i As Long Dim v As Variant Dim vSrc As Variant Dim vDest() As Variant Dim MyLen As Integer
vSrc = Split(Text1.Text, vbCrLf)
For Each v In vSrc If IsNumeric(v) Then ReDim Preserve vDest(i) vDest(i) = Hex(v) i = i + 1 End If Next Text2 = "" For i = 0 To UBound(vDest) MyLen = Len(vDest(i)) If MyLen Mod 2 = 0 Then Text2 = Text2 & vDest(i) & vbCrLf Else Text2 = Text2 & "0" & vDest(i) & vbCrLf End If Next
Dim i As Long
Dim v As Variant
Dim vSrc As Variant
Dim vDest() As Variant
Dim MyLen As Integer
vSrc = Split(Text1.Text, vbCrLf)
For Each v In vSrc
If IsNumeric(v) Then
ReDim Preserve vDest(i)
vDest(i) = Hex(v)
i = i + 1
End If
Next
MyLen = Len(Join(vDest, vbCrLf))
If MyLen Mod 2 = 0 Then
Text2.Text = Join(vDest, vbCrLf)
Else
Text2.Text = "0" & Join(vDest, vbCrLf)
End If
End Sub
Dim a As Long
Dim b As String
a = Val(Text1)
b = Hex(a)
If Len(b) Mod 2 = 0 Then
b = b
Else
b = "0" & b
End If
Text2 = b
End SubPrivate Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub
zdingyun的程序运行直接报错
先在窗体上建立一个Button
两个Text
Private Sub Command1_Click()
Dim a As Long
Dim b As String
a = Val(Text1)
b = Hex(a)
If Len(b) Mod 2 = 0 Then
b = b
Else
b = "0 " & b
End If
Text2.Text = b
End SubPrivate Sub Form_Load()
Text1.Text = " "
Text2.Text = " "
End Sub
Dim i As Long
Dim v As Variant
Dim vSrc As Variant
Dim vDest() As Variant
Dim MyLen As Integer
vSrc = Split(Text1.Text, vbCrLf)
For Each v In vSrc
If IsNumeric(v) Then
ReDim Preserve vDest(i)
vDest(i) = Hex(v)
i = i + 1
End If
Next
Text2 = ""
For i = 0 To UBound(vDest)
MyLen = Len(vDest(i))
If MyLen Mod 2 = 0 Then
Text2 = Text2 & vDest(i) & vbCrLf
Else
Text2 = Text2 & "0" & vDest(i) & vbCrLf
End If
Next
End Sub