vb 关于分组选择问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 00:43:09
现在
a组有123,b组有456,c组有,7890
s=一个3位数的数
d=比较s百位的数属于那个组然后百位输出组名,十位属于那个组然后十位位输出组名,个位属于那个组然后在各位输出组名
如,s=678
d就应该=bcc
如s=158
d就等于abc
那要是a组有145,b组有862,c组有,0379呢

'一个 text1 和一个 command1
Private Sub Command1_Click()
Dim a As String, b As String, c As String, d As String, s As String, temp As String, temp2 As String
a = "145" 'a组
b = "862" 'b组
c = "0379" 'c组
temp2 = Trim(Text1.Text)
For i = 1 To 3
temp = Mid(temp2, i, 1)
If InStr(1, a, temp) > 0 Then d = d & "a"
If InStr(1, b, temp) > 0 Then d = d & "b"
If InStr(1, c, temp) > 0 Then d = d & "c"
Next i
MsgBox "d=" & d
End Sub

新建一个 text1 和一个 command1
输入代码:

Private Sub Command1_Click()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim S As Integer
Dim D As String
On Error Resume Next
S = Text1.Text
If S > 1000 Or S < 100 Then
MsgBox "超出范围"
Text1.Text = ""
Exit Sub
End If
A = Int(S / 100)
B = Int(S