填空题 VB
题号 #1812077

有如图所示的窗体。程序执行时先在Text1文本框中输入编号,当焦点试图离开Text1时,程序检查编号的合法性,若编号合法,则焦点可以离开Text1文本框;否则,显示相应错误信息,并自动选中错误的字符,且焦点不能离开Text1文本框(见图)。

合法编号的组成是:前2个字符是大写英文字母,第3个字符是“_”,后面是数字字符 (至少1个)。下面程序可实现此功能,请填空。
Private SubText1_LostFocus()
Dim k%,n%
N=Len( 【13】 )
For k=1 TO IIf(n>3,n,4)
C=Mid(Textl.Text,k,1)
Select Case k
Case 1,2
If c<“A”Or C>“Z”Then
MsgBox(”第”& k & “个字符必须大写字母!”)
SetPosition k:Exit For
End lf
Case 3
If c<>“_” Then
MsgBox(“第”& k & “个字符必须是字符““_””)
SetPosition k:Exit For
End If
Case Else
If c<“0”Or c>“9” Then
MsgBox(“第”& k & “个字符必须是数字!”)
SetPosition k:Exit For
End If
End Select
Next k
End Sub
Private Sub SetPosition (pos As Integer)
Textl.SelStart=Pos-1:Textl.SelLength= 【14】 :Textl. 【15】
End Sub

进入在线模考

参考答案

暂无

答案解析

-A() ; pList[top]=item

你可能感兴趣的试题

A.Private Sub Check1_click(Index As Integer)
Text1.Text = ""
For k = 0 To 3
If Check1(k).Value = 1 Then
Text1.Text = Text1.Text & Check1(k).Caption & " "?'双引号中是空格
End If
Next k
End Sub
B.Private Sub Check1_Click(Index As Integer)
For k = 0 To 3
If Check1(k).Value = 1 Then
Text1.Text = Text1.Text & Check1(k).Caption & " " '双引号中是空格
End If
Next k
End Sub
C.Private Sub Check1_Click(Index As Integer)
Text1.Text = ""
For k = 0 To 3
If Check1(Index).Value = 1 Then
Text1.Text = Text1.Text & Check1(Index).Caption & " " '双引号中是空格
End If
Next k
End Sub
D.Private Sub Check1_Click(Index As Integer)
Text1.Text = ""
For k = 0 To 3
If Check1(k).Value = 1 Then
Text1.Text = Text1.Text & Check1(k).Caption & " " '双引号中是空格
Exit For
End If
Next k
End Sub?
找试题 · 找答案 · 找资料 在线模考