消息框中的问题 [英] problem in messagebox
本文介绍了消息框中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hei guys
这是我的示例代码
hei guys
this is the sample code of mine
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If Not IsNumeric(TextBox1.Text) Then
hehe:
Dim abc As DialogResult = MessageBox.Show("Please insert numeric only!", "Error!!", MessageBoxButtons.OKCancel)
If abc = DialogResult.OK Then
TextBox1.Clear()
Else
GoTo hehe
End If
End If
End Sub
$我按下确定按钮后b $ b ..
我的文字已经清楚..
但问题是消息框仍然弹出
当我点击
after i press on the ok button..
my text have been clear..
but the problem is the message box still pop out
what show i do to prevent the messagebox pop out again when the ok button is clicked
推荐答案
时,我会做什么来阻止消息框再次弹出<
出现消息框,因为一旦你清除了文本框,它再次成为一个textchange事件,因此,它正在成为一个无限的功能。
所以,请尝试以下代码。
Hi,
The message box appearing, because, once you clear the textbox, again its a textchange event, so, it is becoming an infinite function.
so, try below code.
If TextBox1.Text.Trim <> "" Then
If Not IsNumeric(TextBox1.Text) Then
Dim abc As DialogResult = MessageBox.Show("Please insert numeric only!", "Error!!", MessageBoxButtons.OKCancel)
If abc = DialogResult.OK Then
TextBox1.Clear()
End If
End If
End If
希望有帮助
hope it helps
我建议你:
1)使用TextBox_Leave [ ^ ]事件,而不是 TextBox_TextChange [ ^ ]事件。
2)不要从TextBox中删除文本,而是选择它并将焦点带回TextBox,
3)使用 RegEx [ ^ ]到检查TextBoxvalue是否为数值。
I suggest you:
1) to use TextBox_Leave[^] event, not TextBox_TextChange[^] event.
2) do not remove text from TextBox, but select it and bring focus back into TextBox,
3) use RegEx[^] to check if TextBox "value" is numeric value.
这篇关于消息框中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文