TEXTBOX 字符匹配 问题

zhangyx1 2008-06-18 10:29:03
是这样的 form 上边有4个textbox 一个button
我想在textbox1输入文字 单击button后结果返回textbox2-4
内容如下
我输入3个字符
设置 textbox2 如果第1位输入的是字母 p 就返回正确
设置 textbox3 如果第2位输入的是字母 2 就返回正确
设置 textbox4 如果第3位输入的是字母 x 就返回正确

我该怎么做啊我找了好久msdn都找不到啊谁能帮我写一个啊谢谢了
...全文
70 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
请讲清楚一点啊,就是有一点模糊
神之泪花 2008-06-18
  • 打赏
  • 举报
回复
LZ是想实现在textbox1输入文字 单击button后结果返回textbox2-4

还是,判断输入在其他textbox的返回值?
taick 2008-06-18
  • 打赏
  • 举报
回复
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim str As String = TextBox1.Text
If Mid(str, 1, 1) = "p" Then
TextBox2.Text = "正确"
Else
TextBox2.Text = "错误"
End If
If Mid(str, 2, 1) = "2" Then
TextBox3.Text = "正确"
Else
TextBox3.Text = "错误"
End If
If Mid(str, 3, 1) = "x" Then
TextBox4.Text = "正确"
Else
TextBox4.Text = "错误"
End If
End Sub
zhangyx1 2008-06-18
  • 打赏
  • 举报
回复
楼上的谢谢问题解决了
gh_li 2008-06-18
  • 打赏
  • 举报
回复
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Dim str As String = txtbox1.text
If String.Compare(str.Substring(0, 1), "p") = 0 Then
txtbox2.text = "正确"
End If
If String.Compare(str.Substring(1, 1), "2") = 0 Then
txtbox3.text = "正确"
End If
If String.Compare(str.Substring(2, 1), "x") = 0 Then
txtbox4.text = "正确"
End If
End Sub
mfineky 2008-06-18
  • 打赏
  • 举报
回复
Dim str1 As String = TextBox1.Text
If Mid(str1, 2, 1) = "p" Then
Response.Write("Right")
End If
     'Mid(str1,3,1)="2"
'Mid(str1,4,1)="x"

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧