Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
Generalconditions problem Pin
nidhelp4-Aug-05 16:47
nidhelp4-Aug-05 16:47 
GeneralRe: conditions problem Pin
Mohamad Al Husseiny4-Aug-05 16:50
Mohamad Al Husseiny4-Aug-05 16:50 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 16:58
nidhelp4-Aug-05 16:58 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 17:35
protectorChristian Graus4-Aug-05 17:35 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:07
nidhelp4-Aug-05 18:07 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 18:14
protectorChristian Graus4-Aug-05 18:14 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:32
nidhelp4-Aug-05 18:32 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 18:56
protectorChristian Graus4-Aug-05 18:56 
nidhelp wrote:
hmmmm.. i need to ensure that the user only types s/S or f/F for the first letter.. how is that possible?

A regex can contain more specific info, [] is used for character groups.

[sSfF]\d{7}[sSfF]

will do it. OnKeyPress will give you a function that runs when a key is pressed. In that function, you need to get the text from the textbox and check it. Something like this:

TextBox tb = sender as TextBox;

string input = tb.Text;

if (input.Length == 9 && System.Text.RegularExpressions.Regex.Match(input, @"[sSfF]\d{7}[sSfF]").Success)
{
// The string is correct
}
else
{
// Don't forget that unless the length is 9, they could still be entering, so don't put a warning box here. A better place for that would be the lose focus event.
}




Christian Graus - Microsoft MVP - C++
GeneralRe: conditions problem Pin
Luis Alonso Ramos4-Aug-05 19:12
Luis Alonso Ramos4-Aug-05 19:12 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 19:16
nidhelp4-Aug-05 19:16 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 19:23
protectorChristian Graus4-Aug-05 19:23 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 19:37
nidhelp4-Aug-05 19:37 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 19:45
protectorChristian Graus4-Aug-05 19:45 
GeneralRe: conditions problem Pin
Weiye Chen4-Aug-05 17:51
Weiye Chen4-Aug-05 17:51 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:41
nidhelp4-Aug-05 18:41 
GeneralRe: conditions problem Pin
J4amieC4-Aug-05 22:39
J4amieC4-Aug-05 22:39 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 23:24
nidhelp4-Aug-05 23:24 
GeneralRe: conditions problem Pin
J4amieC4-Aug-05 23:46
J4amieC4-Aug-05 23:46 
GeneralRe: conditions problem Pin
nidhelp5-Aug-05 0:02
nidhelp5-Aug-05 0:02 
GeneralRe: conditions problem Pin
mav.northwind5-Aug-05 2:59
mav.northwind5-Aug-05 2:59 
GeneralRe: conditions problem Pin
nidhelp7-Aug-05 15:14
nidhelp7-Aug-05 15:14 
GeneralRe: conditions problem Pin
nidhelp5-Aug-05 0:00
nidhelp5-Aug-05 0:00 
GeneralRe: conditions problem Pin
J4amieC5-Aug-05 0:18
J4amieC5-Aug-05 0:18 
Generalabout finding forms Pin
papyrus_lei4-Aug-05 16:34
papyrus_lei4-Aug-05 16:34 
GeneralRe: about finding forms Pin
Mohamad Al Husseiny4-Aug-05 17:15
Mohamad Al Husseiny4-Aug-05 17:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.