|
No, that is useless. It will only accept one string. Why bother concatenating 5 values to check if the user typed 999-999-9999 ? How often would that be the number the type ?
I'm not sure in VB, but in C# it's
string [] strings = theString.Split("-");
I suspect it would be
string () strings = theString.Split("-")
but I could be wrong. Then you can check if the array has three elements, and what their lengths are. A regex will tell you if they followed the format, but not how they failed to follow it. It depends on how much detail you want in your error message.
Christian Graus - Microsoft MVP - C++
-- modified at 23:11 Thursday 27th October, 2005
|
|
|
|
|
All of the error messages will be handled via MsgBox message, that is why I have to code for the dashes and the numbers. Now should I code this all under the button1.clicked function or should I delcare my TextBox as a global variable then I can code everything under the button1.clicked Private Sub?
|
|
|
|
|
12String wrote: All of the error messages will be handled via MsgBox message, that is why I have to code for the dashes and the numbers.
Yes, but you don't need to code it the way you have, and you shouldn't code it outside the function that validates the input.
12String wrote: Now should I code this all under the button1.clicked function
As another function, I think so.
12String wrote: should I delcare my TextBox as a global variable
This is always a hideous idea.
You have what you need in the checknumeric function, except what's in it is wrong. Remove the other code with the messageboxes, and instead add something which will work inside that function.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So I should leave the Public Sub CheckInput() as is and delete the above msgBoxes? any suggestions on what to put in thier place LOL.
|
|
|
|
|
12String wrote: any suggestions on what to put in thier place LOL.
Exactly what I've suggested already - you can split the strings by the -, and then check the rest is numbers of the right length, or use a regex.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The problem is the how. I do not know how to code it. Exactly how would you code it. I cannot find any examples or close to examples in this text I have it is most frustrating.
|
|
|
|
|
The regex I provided will work with Regex.IsMatch ( from memory ), otherwise I've given you the syntax for the split function, and said that you need to use Double.TryParse to see if they are numnbers. I'm reluctant to do much more, that should be enough for you to find out the rest, and as this is homework, the point is learning, not just doing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Herein lies another problem, when I enter the string()strings=string.split("-") VB gives me a syntax error stating that 'String is a class type, and so is not valid. Also Name 'TheString'is not declared. UFFFFF! You see my frustration. LOL
|
|
|
|
|
12String wrote: You see my frustration. LOL
Yes, the problem is that you're looking for a cut and paste solution instead of thinking about it.
string.split is my way of showing you where this function lives
myString.split obviously requires you to replace myString with the name of the variable that holds the string in your program.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian, you deserve some sort of an award You are certainly blessed with above average patience!
...Steve
|
|
|
|
|
I regard it as a challenge at times to lead people to their required solution. It would be easy just to give him the code, but that's not really helping him, is it ?
Having aspirations to project management, I need to work on my communication skills anyhow
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: It would be easy just to give him the code, but that's not really helping him, is it ?
Bravo! One of the few who thinks it's better to learn by doing (and screwing it up!) than by having it spoon fed to you!
To offer a different answer to his problem though... I've always done one of two things. Either used a Masked Edit Box or (more directly to his problem) just let the user type whatever they wanted into the box. Then in the validation or submit process, strip out everything that wasn't a number to create a string of numbers, measure the length for completeness, then put the dashes and parentheses (if needed) back in where they're supposed to go. Walla! Instant phone number that can be re-edited at any time, if needed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: Masked Edit Box
Yeah, the easiest way to validate is to only let the user type in something that is valid I can't recall if it was apparent if this was a web or windows UI though. I know it can be done with a web UI, but I tend to shun Jscript as I fear browser issues.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Just a thought, what if we create a custom textbox which allow you to type only numbers and inserts "-" at proper places automaitcally
- ashish
|
|
|
|
|
How would we go about doing that?
|
|
|
|
|
I know generally how to raise and detect/handle events in my own programs, but how does one detect system events? I can't imagine there aren't events raised when someone selects a start menu item, much less something like a system error or a new usb device being inserted.
anyone have a few hints where to start looking for things like this? and what about making my programs raise system-wide events? are all events system-wide(if they are public that is)? thanks to anyone with this info.
sincerely, Brett Peirce - PolerBear
To err is human; To forgive: divine.
|
|
|
|
|
There are code samples for HID/USB events around. A start menu item, I'm not so sure of, but you can write global hooks for global events, in C++ at least.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Lot of stuff all together.
There are classes in the .NET Framework you can use to get some system events (i.e. FileSystemWatcher, ...)
Others, like USB or PCMCIA insertion have some sample code around here (as stated in previous reply)
I don't believe a there's a system event for a start menu selection. Only way could be to get all the system msg but I guess you need to use something different than VB.NET (I may be wrong).
To generate system event is a slightly diffent, and depends on what do you mean. Create "fake" events? Notify every task of something (or only some "listening" tasks?)?
|
|
|
|
|
Hi,
I want to Change the date format(which is comming for Date Time picker control) to YYYYMMDD.
Plz help me.
regards,
Paritosh
Paritosh
|
|
|
|
|
Hi,
I'm only do work in C# but i am sure about you can do this small work by yourself. Anyways...
On desgin Time
change date picker control Properties (Press F4)
===========================
CustomFormt = yyyyMMdd
Format = Custom
================
Through codeing change date format
string dt = dateTimePicker.Value.ToString("yyyyMMdd");
MessageBox.Show(dt);
Hope this work!
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
Hope this works for u.
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
TextBox1.Text = DateTimePicker1.Value
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DateTimePicker1.CustomFormat = "yyyy/MM/dd"
DateTimePicker1.Format = DateTimePickerFormat.Custom
End Sub
End Class
|
|
|
|
|
Is it possible to develop a user control or windows form that can be embeded in an html document. The html document will not necessarily be served by a web server but may be located on the local machine.
If so, is it possible to have this control/windows form automatically deployed using click once?
I'm essentially trying to mimic an ActiveX control being embeded into an html document.
Thanks
|
|
|
|
|
Hi, suppose i have username, password, ISP phone number and i want to create network connection to dial to that ISP. How could i create the dial up connection from vb.net by using the information that I have above?
|
|
|
|
|
hi there,
You might play with WinInet API
WinInet API
<< >>
|
|
|
|
|
Hi Everybody
I'd like to know if there's a way to put a reference on a Visual Basic project to a OpenOffice.org program to run it and control it from my Visual Basic Application. I know that we can do this with Microsoft Office applications, in fact I'm using Excel in my project but I'd like to try something different as OpenOffice Calc for example. I searched in the internet but I didn't find anything If you know something about, then please let me know.
Thanks in advance.;)
TK
|
|
|
|