Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted
The .NetFramework 2.0 has a masked textbox control which allows you to set a mask for input. You also need to verify the values entered, making sure that each number is less than 256.
[sIGPIC]e[/sIGPIC]
Posted

thanks... however, i'm having difficulties to convert the string of the masked textbox to int to see if it's less than 256...

 

Private Sub mtxtLIP_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles mtxtLIP.KeyUp
       Dim segments As String() = mtxtLIP.Text.Split(".")
       Dim segment As String

       For Each segment In segments
           If segment > 255 Then
               picLIP.Visible = True
           Else
               picLIP.Visible = False
           End If
       Next
   End Sub

 

Obviously, this doesn't work... but I tried many int conversions and none of them worked...

Posted

If int.Parse(segment) > 255 Then

*NB it sounds like your using .Net 2.0 in which case you could use TryParse(), if you do however note the overload is different to Parse()

Anybody looking for a graduate programmer (Midlands, England)?
Posted
If int.Parse(segment) > 255 Then

*NB it sounds like your using .Net 2.0 in which case you could use TryParse(), if you do however note the overload is different to Parse()

 

 

That didn't work, nor Integer.parse() I had to solve it with the tryparse()

 

thanks...

 

I thought I had option strict on but I guess I was wrong. If I enable it globally in the options, I'll still have to add it to my program right? Unless I start to create a new project... right or wrong?

Posted
Thats my fault int is a C# type. Perhaps Single.Parse() would have worked better.
Anybody looking for a graduate programmer (Midlands, England)?
  • *Experts*
Posted

I did a google search for "IP Address textbox c#" without the quotes and came up with the following:

http://www.codeproject.com/cs/miscctrl/IPAddressTextBox.asp

 

He address a LOT more issues that you were/are probably interested in, but still might prove useful. Glad to see you got the parsing fixed. :)

 

Note: I didn't actually look in detail at what was posted so I'm not saying it's definitely an example of clean code. Just thought I'd offer up the link in case it happens to work for you.

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...