Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Accepts one of 1, 2, x or X, or nothing

private Boolean patternIsMatch(String text) {
	// Alternatives; one of 1, 2, x or X, or nothing is accepted pattern.
	Regex pattern = new Regex(@"^([12xX]{1}|^)$");
	return pattern.IsMatch(text);
}
private void textBoxAnswer_TextChanged(object sender, EventArgs e) {
	if (!patternIsMatch(textBoxAnswer.Text)) {                
		MessageBox.Show(textBoxAnswer.Text + " = Felaktigt värde");
		textBoxAnswer.Text = "";
	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: skrivetænking 
Csharp :: c# ipaddress to integer 
Csharp :: asp.net core user.identity.name is null 
Csharp :: C# WriteLine() and Write() 
Csharp :: how to specify order of test in c# 
Csharp :: c# (sharp) varibles 
Csharp :: download and run exe c# 1 button 
Csharp :: firepower 4125 License update 
Csharp :: uity pause game 
Csharp :: unity manager.instance 
Csharp :: C# Associativity of Operators 
Csharp :: unity photon base onenable 
Csharp :: how to do minus with button c# 
Csharp :: soundplayer c# take uri 
Csharp :: linq select distinct 
Csharp :: populate toolstripitems to combobox 
Csharp :: esaddex34 
Csharp :: c# linq foreach example 
Csharp :: unity save slots 
Csharp :: trigger checkbox combobox wpf 
Csharp :: and in c# 
Csharp :: unity Polymorphism 
Csharp :: get patht bim 360 revit api 
Csharp :: c# psobject get value 
Csharp :: dynamic c# .add 
Csharp :: screenshot c# WinForms 
Csharp :: create viewport revit api 
Csharp :: c# Search specified string inside textbox 
Csharp :: custom vscode snippet 
Csharp :: c# datagridview filter 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =