VB循环问题
发布网友
发布时间:2022-05-07 10:28
我来回答
共5个回答
热心网友
时间:2023-10-26 02:02
Mid(i,1)改成Mid(s,i,1),你都没把s弄进去……
然后,我猜你的Text1.Text是不是都应该改成s?
其实有更好的方法,直接这样
s = Replace(s, "A", "00")
s = Replace(s, "B", "01")
s = Replace(s, "C", "000")
s = Replace(s, "D", "0010")
s = Replace(s, "E", "0011")
这样处理更方便。
热心网友
时间:2023-10-26 02:02
加一句do while not rs.eof
热心网友
时间:2023-10-26 02:03
Dim s As String
Dim s1 As String
Dim m As String
s = "EACBAADBCA"
s1=""
For i = 1 To Len(s)
Select Case Mid(i, 1)
Case "A"
m = "00"
Case "B"
m = "01"
Case "C"
m = "000"
Case "D"
m = "0010"
Case Else
m = "0011"
End Select
s1=s1 & m
Next i
List2.AddItem s1
热心网友
时间:2023-10-26 02:03
Dim s As String, s1 As String
Dim s2 As String
Private Sub Command1_Click()
s = "EACBAADBCA"
For i = 1 To Len(s)
s1 = Mid(s, i, 1)
a (s1)
Next i
List2.AddItem s2
End Sub
Sub a(s1 As String)
Select Case s1
Case "A"
s1 = Replace(s1, "A", "00")
s2 = s2 + s1
Case "B"
s1 = Replace(s1, "B", "01")
s2 = s2 + s1
Case "C"
s1 = Replace(s1, "C", "000")
s2 = s2 + s1
Case "D"
s1 = Replace(s1, "D", "0010")
s2 = s2 + s1
Case Else
s1 = Replace(s1, "E", "0011")
s2 = s2 + s1
End Select
End Sub
按照楼主的意思我改动了一下。
热心网友
时间:2023-10-26 02:04
static s As String
s = "EACBAADBCA"
For i = 1 To Len(s)
Select Case Mid(i, 1)
Case "A"
s = Replace(Text1.Text, "A", "00")
Case "B"
s = Replace(Text1.Text, "B", "01")
Case "C"
s = Replace(Text1.Text, "C", "000")
Case "D"
s = Replace(Text1.Text, "D", "0010")
Case Else
s = Replace(Text1.Text, "E", "0011")
End Select
Next i
List2.AddItem s
试试看喽