在VB中在text1输入1个字母 label1输出其前导字母label输出后续字母 求程序代码
7个回答
展开全部
自己动手丰衣足食,思路是获取B的keydown事件,接收到ascii值,加1减1后转换成字符赋给label1和label2,需要注意的是边界字母A和Z。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'Text1清空文字
Private Sub Text1_KeyPress(KeyAscii As Integer)
Text1.Text = ""
If KeyAscii < 90 And KeyAscii > 65 Then
Label1.Caption = Chr(KeyAscii - 1)
Label2.Caption = Chr(KeyAscii + 1)
End If
If KeyAscii > 97 And KeyAscii < 122 Then
Label1.Caption = Chr(KeyAscii - 1)
Label2.Caption = Chr(KeyAscii + 1)
End If
End Sub
'这样就行了。 还区分大小写。
Private Sub Text1_KeyPress(KeyAscii As Integer)
Text1.Text = ""
If KeyAscii < 90 And KeyAscii > 65 Then
Label1.Caption = Chr(KeyAscii - 1)
Label2.Caption = Chr(KeyAscii + 1)
End If
If KeyAscii > 97 And KeyAscii < 122 Then
Label1.Caption = Chr(KeyAscii - 1)
Label2.Caption = Chr(KeyAscii + 1)
End If
End Sub
'这样就行了。 还区分大小写。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim lblfirst As String
Dim lblnext As String
If Text1.Text = "" Then
MsgBox "请输入字母"
Exit Sub
End If
lblnext = Chr(Asc(Text1.Text) + 1)
lblfirst = Chr(Asc(Text1.Text) - 1)
Label1.Caption = lblfirst
Label2.Caption = lblnext
End Sub
测试通过,VB6平台
Dim lblfirst As String
Dim lblnext As String
If Text1.Text = "" Then
MsgBox "请输入字母"
Exit Sub
End If
lblnext = Chr(Asc(Text1.Text) + 1)
lblfirst = Chr(Asc(Text1.Text) - 1)
Label1.Caption = lblfirst
Label2.Caption = lblnext
End Sub
测试通过,VB6平台
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加入text1 text2 text3三个控件
在text1下输入如下代码
Private Sub Text1_Change()
a = Asc(Text1.Text)
Text2.Text = Chr(a - 1)
Text3.Text = Chr(a + 1)
End Sub
在text1下输入如下代码
Private Sub Text1_Change()
a = Asc(Text1.Text)
Text2.Text = Chr(a - 1)
Text3.Text = Chr(a + 1)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Label1.AutoSize = True
Label2.AutoSize = True
Text1.Text = ""
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then Exit Sub
If Asc(Text1.Text) > 96 And Asc(Text1.Text) < 122 Or Asc(Text1.Text) > 65 And Asc(Text1.Text) < 90 Then
Label1.Caption = Chr(Asc(Text1.Text) - 1)
Label2.Caption = Chr(Asc(Text1.Text) + 1)
End If
End Sub
Label1.AutoSize = True
Label2.AutoSize = True
Text1.Text = ""
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then Exit Sub
If Asc(Text1.Text) > 96 And Asc(Text1.Text) < 122 Or Asc(Text1.Text) > 65 And Asc(Text1.Text) < 90 Then
Label1.Caption = Chr(Asc(Text1.Text) - 1)
Label2.Caption = Chr(Asc(Text1.Text) + 1)
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询