金星评价tfboys:一个VB的简单问题

来源:百度文库 编辑:高考问答 时间:2024/04/29 03:37:33
比如
如果text1这个文本控件中含有"1"和"2"
这两个数字(不一定连续)
就text2.text="123"

这个简单的程序怎么写

if contain(text1.text,12) then
text2.text="123"
end if

这里是只用一个按键做例子

Private Sub Command1_Click()
Dim b, c As Integer
Dim a, x As String
a = Text1.Text
i = 0
Do
If b + c = 2 Then
Exit Do
End If
i = i + 1
x = Mid(a, i, 1)
If x = "1" Then
b = 1
ElseIf x = "2" Then
c = 1
End If
Loop
Text2.Text = 123
b = 0
c = 0
i = 0
End Sub

If InStr(1, Text1.Text, "1") <> 0 And InStr(1, Text1.Text, "2") <> 0 Then
text2.text="123"
End If