|
Thanks, I hadn't thought of that.
|
|
|
|
|
I have created a VB.Net application running on Win XP prof and when I run the program, all seems fine, but all of a sudden the program seems to shutdown. I have added Try-catch statements to all of my functions hoping to catch where it is failing, but no error message comes up. Can anyone help me with this?
Thanks
|
|
|
|
|
The only thing you can do is instrument your code and have it log what it's doing, like entering functions, function parameter values and return values. You'll get a better idea of where this sudden quit is occuring.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Having trouble deciphering the following code. Am I leaving something out or do I need to subtract something or am I way off in left field? Bold area is my main problem at this moment. Thanks
Private Sub Number_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Number.TextChanged
Number.MaxLength = 12
Dim Mystr As String
Dim ok As Boolean = (Number.IndexOf("-") = 3 And Number.LastIndexOf("-") = 7)
If Number.Text.Length = 3 OrElse Number.Text.Length = 7 Then
Number.Text = Number.Text & "-"
Number.Select(Number.Text.Length, 0)
End If
Mystr = Format(222 - 22 - 2222, "###-###-####")
If Number.Text.Length = 12 Then
Number.Visible = True
End If
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
What are you asking? Are you trying to figure out what the highlighted code does?
If so, it's checking two things. First, does the index of the first "-" character = 3, returning true or false. Then it AND's that to a check to see if the last index of "-" character is 7. The results is a boolean value, true of false saying if these characters are at those positions.
But, it has a serious flaw. What if there is more than two "-" characters in the string?
A better way to do this would be to accept only number characters, or to accept any characters and use the textbox's Validating event to reformat the text in the box.
When the Validating event fires, take the string in the textbox and strip out everything that isn't a numeric character. Then take the end result and make sure there are 9 characters (for an SSN anyway), if not, throw up a messagebox. If you have 9 characters, build a new string with the formatting "-" in it and set the textbox's Text property to that.
For example, I've seen something like this for text entry of a Social Security Number:
Private Sub SSN_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SSN.Validating
Dim tempSSN As String = String.Empty
' Create a temporary string that contains only the
' numbers in the original string as typed by the user.
For i As Integer = 0 To SSN.Text.Length - 1
If IsNumeric(SSN.Text.Chars(i)) Then
temp &= SSN.Text.Chars(i)
End If
Next
If tempSSN.Length = 9 Then
' We should have a string of numbers that looks like this: 295048397
' Reformat it to look like this: 295-04-8397
SSN.Text = String.Format("{0}-{1}-{2}", _
tempSSN.SubString(0, 3), _
tempSSN.SubString(3, 2), _
tempSSN.SubString(5, 4))
SSN.BackColor = Color.White
e.Cancel = False
ElseIf tempSSN.Length <> 0 Then
' If the length is now anything other than 0 or 9, clear
' the textbox and color it red to point out that we need a valid
' SSN in this box to continue.
SSN.Text = String.Empty
SSN.BackColor = Color.Red
e.Cancel = True
Else
' Since the SSN length is 0, it's OK to not have an SSN. Clear
' the textbox and return it to normal.
SSN.Text = String.Empty
SSN.BackColor = Color.White
e.Cancel = False
End If
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok let me see if I can transalte this to my telephone validater program and will repost because I know I will still be confused. Don't know how you guys got so good at this.
Believe me guys, I am totally confused.
|
|
|
|
|
Another question. Just how do you place a Masked Edit Control on a form. I see where you code the code but how do you actually place a masked edit control on the form itself i.e. a form that will only allow numbers to be typed in. Think the code would be:
With MaskEdBox1
.Mask = "###-###-####"
.PromptChar =""
End With
End Sub
I just can't get past the MaskedBox1 saying that it's not declared.
Believe me guys, I am totally confused.
|
|
|
|
|
Right-click in the ToolBox and select Add/Remove Items. You can then click on the COM tab and find the Microsoft MaskedEdit Control. Click the checkmark next to that line, then click OK. YOu can then drag the control out from the ToolBox onto your form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks again guy, you're the greatest. Hate being a pain though. On my previous code after adding a mask edit box, should it not prevent numbers from being type in. Btw, when I added the maskeditbox it loaded as AxMaskEdBox1 so I changed the code to that also but it still allows other characters. Here it is again.
Private Sub Form1_Load()
With AxMaskEdBox1
.Mask = "############"
.PromptChar = ""
End With
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
Forget it. No longer a problem.
Believe me guys, I am totally confused.
|
|
|
|
|
Maybe I need to be a little more specific. Here's what I'm trying to do. I'm trying to limit my text box to 12 numeric characters whereas two of the characters are dashes(-). I feel if I can get this taken care of I might be able to further produce the code I need but without this box functioning correctly all the other codes will be mute. Thanks
Believe me guys, I am totally confused.
|
|
|
|
|
Do the dashes have to be in the exact same place every time? Are you talking about a North American phone number?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes but after working on it I was able to figure that one out. Still having problem with the code but at least I got that part. For some reason, my message box does not appear when I click on the validate button but when I click on the exit button. These projects are killing me, guess that's what school is all about. Once I get that worked out, the only thing left will be to break it down into area code, prefix and suffix substrings textboxes. Getting there.
Private Sub Button1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Button1.Validating<br />
<br />
If Phone.Text.Length = 12 Then<br />
MsgBox("You have entered a valid phone number")<br />
ElseIf Phone.Text.Length <> 0 Then<br />
Phone.Text = String.Empty<br />
Phone.BackColor = Color.Red<br />
e.Cancel = True<br />
Else<br />
Phone.Text = String.Empty<br />
Phone.BackColor = Color.Plum<br />
e.Cancel = False<br />
End If<br />
End Sub
Believe me guys, I am totally confused.
|
|
|
|
|
I've got MSDN integrated help installed with my copy of VS.net. The mouseover function descriptions work fine in C#, but don't even want to know in VB.
Where can i enable this feature so that mousovers in VB will display a description of the function / object, etc.
Cheers
Tris
|
|
|
|
|
It should be enabled by default. I don't know where it is, but you might want to check under Tools/Options/Environment.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well, i checked all these settings first. It was odd because it's enabled and works fine with C#. I'm not sure if it's a problem with VB, or VS.net?
Any more ideas? Is this a known issue? Or shouldn't it happen?
Cheers
Tris
|
|
|
|
|
I haven't heard of it happening. My next check would be the VS.NET installation log.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I was wondering if anyone knew how to create only one instance of an application. I have created a startup module to run my application but I would like to prevent the user from opening more than one instance of my application.
How would I approach this? Would I need to check for an existing process or form instance? Could someone point me in the right direction?
Any guidance would be much appreciated. Thanks.
|
|
|
|
|
Search the articles for "single instance" and you'll come up with a bunch of ideas. Results[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave
|
|
|
|
|
I found an easy way of accomplishing this. In the startup module simply put:
If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName()).Length > 1 Then Exit Sub
|
|
|
|
|
I have a Tab Control on my form with 4 tabs
How can I via code, default back to tab 1 or how can I default to tab 1
Any ideas?
|
|
|
|
|
TabControl1.SelectedIndex = 0
Selects the first tab added to the control. The index is zero based, so tab page 1 would be index 0, tab page 2 would be index 1, ...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a text file that was generated from a report that is in a strange format. I need to be able to convert this to a text file that can be used to import into an access database. I have no idea how to go about this and a helping hand in terms of what functions to read up on or websites (please not mdsn or google) but a tutorial on how to do this would be great.
Here is an example of what i mean.
<br />
7/20/2005 8:14 AM A C C O U N T M A S T E R R E P O R T PAGE: 1<br />
ZONE: < All Zones > STATUS: ALL<br />
<br />
---ACCOUNT---- ------------NAME------------ CLASS -STATUS- -SERVICE / MAILING ADDRESS--<br />
------------------------------------------------------------------------------------------------------------------------------------<br />
01-0005-00 PHILLIPS & LUCKEY COM ACTIVE 555 blahstreet<br />
PO BOX 1417 Blah, TX 1234567, B009<br />
<br />
SERVICES: ==METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION---- SCALE DIALS UNITS METER NO# LAST READ DATE LAST READING<br />
10-WATER 5 Y COMMERCIAL 1.000 7 1.00 56914331 6/05 0<br />
<br />
==NON METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION----- STEP/QUAN ---AMOUNT--- ---TYPE---<br />
<br />
01-0010-00 ROCKDALE School COM INACTIVE 166 Hello Steet<br />
PO BOX 111 Blah, TX 765670632, B099<br />
<br />
SERVICES: ==METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION---- SCALE DIALS UNITS METER NO# LAST READ DATE LAST READING<br />
10-WATER 5 Y COMMERCIAL 1.000 7 1.00 58456106 6/05 285<br />
<br />
==NON METERED==<br />
-SERVICE CODE- TBL ACT ----DESCRIPTION----- STEP/QUAN ---AMOUNT--- ---TYPE---<br />
40-SEWAGE 5 Y COMMERCIAL 00 0.00 DEPEND<br />
It needs to somehow be placed in a text file that access will understand (headers and field information). Any and all help would be appreciated on this. Thank you for your help.
Win32newb
"Programming is like sex, make one mistake and you have to support it for a long time"
|
|
|
|
|
win32newb wrote:
I have no idea how to go about this and a helping hand in terms of what functions to read up on or websites (please not mdsn or google) but a tutorial on how to do this would be great.
Well, there's the problem. There is no one tutorial to teach you how to do this. You have to read up on stuff like Reading/Writing Text Files, control-break processing, parsing strings, database creation, database access, and RegEx expressions might be helpful too. If you can find a single tutorial for all this, great! You're on your way.
But, chances are you're going to have to use Google to find multiple examples of each topic to get to know how to do each thing seperately. Then you'll have to figure out how each item will fit together to get an application that you want. This is the part that you won't find a tutorial on.
The hardest part of all this is reading a line then trying to figure out what kind of line you read. This can be minimized by closly examining your data and determining each each type of line contains so you can code some kind of recognition method. After you that, this method can then call an appropriate parser to actually get the data out of the line.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|