Anyone knows how I can read a string value from a textbox (e.g.:, split the values using a delimiter, store the values and convert them into int for later use?


string[] parts = textBox1.Text.Split('.');
foreach (string str in parts) {
    int myInt;
    if (Int32.TryParse(str, out myInt)) {
        // Do something with the value in myInt
    } else {
        // the string wasn't an integer, can do something if I want

You should be able to do

string[] octets = ipTextBox.Text.Split('.');
int octet1 = Convert.ToInt32(octets[0]);
int octet2 = Convert.ToInt32(octets[1]);
//... etc.

But if you're specifically using an IP address, I'm sure there's a constructor for an IP address object of some sort that takes a string in dotted-decimal notation for an IP address IPAddress myIP = new IPAddress(ipTextBox.Text);

Alrights thanks all. My problem has been solved.