VB 穷举问题
程序运行要求:在text1中输入“a”在text2中输入“zz”那么list1中就会出现:abcdef.....aaabac....zxzyzz不知道VB能否实现...
程序运行要求:
在text1中输入“a”在text2中输入“zz”那么list1中就会出现:
a
b
c
d
e
f
.....
aa
ab
ac
....
zx
zy
zz
不知道VB 能否实现 展开
在text1中输入“a”在text2中输入“zz”那么list1中就会出现:
a
b
c
d
e
f
.....
aa
ab
ac
....
zx
zy
zz
不知道VB 能否实现 展开
1个回答
展开全部
你这是ecexl里的列标。
直接使用数字序号即可。
如不是,就循环。(假定只限于2位,如果有其他要求,可以自己修改)
Dim s1 As String, s2 As String
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "上下界限不完整"
Exit Sub
End If
If Len(Text1) = 1 Then
s1 = " " & Text1
Else
s1 = Text1
End If
If Len(Text2) = 1 Then
s2 = " " & Text2
Else
s2 = Text2
End If
If s1 > s2 Then
s = s1
s1 = s2
s2 = s
End If
tianjia " "
For i = 1 To 26
tianjia Chr(i + Asc("A") - 1)
Next i
Command1.Enabled = False
End Sub
Private Sub tianjia(s As String)
For i = 1 To 26
s0 = s & Chr(i - 1 + Asc("A"))
If s0 >= s1 And s0 <= s2 Then List1.AddItem Trim(s0)
Next i
End Sub
Private Sub Form_Load()
List1.Clear
Text1.MaxLength = 2
Text2.MaxLength = 2
Text1 = ""
Text2 = ""
End Sub
Private Sub Text1_Change()
For i = 1 To Len(Text1)
l = Mid(Text1, i, 1)
If l < "A" Or l > "Z" Then
MsgBox "输入非法"
Text1 = ""
Exit Sub
End If
Next i
End Sub
Private Sub Text2_Change()
For i = 1 To Len(Text2)
l = Mid(Text2, i, 1)
If l < "A" Or l > "Z" Then
MsgBox "输入非法"
Text2 = ""
Exit Sub
End If
Next i
End Sub
直接使用数字序号即可。
如不是,就循环。(假定只限于2位,如果有其他要求,可以自己修改)
Dim s1 As String, s2 As String
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "上下界限不完整"
Exit Sub
End If
If Len(Text1) = 1 Then
s1 = " " & Text1
Else
s1 = Text1
End If
If Len(Text2) = 1 Then
s2 = " " & Text2
Else
s2 = Text2
End If
If s1 > s2 Then
s = s1
s1 = s2
s2 = s
End If
tianjia " "
For i = 1 To 26
tianjia Chr(i + Asc("A") - 1)
Next i
Command1.Enabled = False
End Sub
Private Sub tianjia(s As String)
For i = 1 To 26
s0 = s & Chr(i - 1 + Asc("A"))
If s0 >= s1 And s0 <= s2 Then List1.AddItem Trim(s0)
Next i
End Sub
Private Sub Form_Load()
List1.Clear
Text1.MaxLength = 2
Text2.MaxLength = 2
Text1 = ""
Text2 = ""
End Sub
Private Sub Text1_Change()
For i = 1 To Len(Text1)
l = Mid(Text1, i, 1)
If l < "A" Or l > "Z" Then
MsgBox "输入非法"
Text1 = ""
Exit Sub
End If
Next i
End Sub
Private Sub Text2_Change()
For i = 1 To Len(Text2)
l = Mid(Text2, i, 1)
If l < "A" Or l > "Z" Then
MsgBox "输入非法"
Text2 = ""
Exit Sub
End If
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询