for i=1 to len(text1.text) me("label" & i).caption=mid(text1.text,i,1) next
Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 And Len(Text1.Text) = 5 Then Label1.Caption = Mid(Text1.Text, 1, 1) Label2.Caption = Mid(Text1.Text, 2, 1) Label3.Caption = Mid(Text1.Text, 3, 1) Label4.Caption = Mid(Text1.Text, 4, 1) Label5.Caption = Mid(Text1.Text, 5, 1) End If End Sub
Option ExplicitPrivate Sub Command1_Click() Dim Length As Long Dim i As Long
Text1.Text = "ABCDE" Length = Len(Text1.Text) '文本框字符长度 For i = 1 To Length If i <= 5 Then Me("label" & CStr(i)).Caption = Mid$(Text1.Text, i, 1) End If Next i End Sub
Dim str1 As String str1 = text1.text if str1<>"" then For i = 1 To Len(str1) 'len() 求字符串长度函数 if i<=5 then Me("label" & i).Caption = Mid(str1, i, 1) Else Exit For End If Next endif
for i=1 to len(text1.text)
me("label" & i).caption=mid(text1.text,i,1)
next
If KeyAscii = 13 And Len(Text1.Text) = 5 Then
Label1.Caption = Mid(Text1.Text, 1, 1)
Label2.Caption = Mid(Text1.Text, 2, 1)
Label3.Caption = Mid(Text1.Text, 3, 1)
Label4.Caption = Mid(Text1.Text, 4, 1)
Label5.Caption = Mid(Text1.Text, 5, 1)
End If
End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim Length As Long
Dim i As Long
Text1.Text = "ABCDE"
Length = Len(Text1.Text) '文本框字符长度
For i = 1 To Length
If i <= 5 Then
Me("label" & CStr(i)).Caption = Mid$(Text1.Text, i, 1)
End If
Next i
End Sub
str1 = text1.text if str1<>"" then
For i = 1 To Len(str1) 'len() 求字符串长度函数
if i<=5 then
Me("label" & i).Caption = Mid(str1, i, 1)
Else
Exit For
End If
Next
endif