Click here to Skip to main content
14,924,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone.

I am very limited on my skills, i am using in .net 4 Framework. I was wondering if someone could assist. i have searched google finding mimial result, im not sure if i am using the correct terminalogy for what i want to achieve...
but basicallyI have a form with a 4 textboxs(txtinfo, txtip, txthost, txttime) When the form loads it loads a textfile to TXTINFO. (please see below)

IP Address:, Host: RTR-BIF01,Time: 18:00 GMT

My issue is from this string i want to be able to pull out the nessary info to display in the other textboxs, soo i want to remove the Header names - IP, Host, time...example

txtip.text = ""
txthost.text = "RTR-BIF01"
txttime.text = today.toshorttime.tostring

Any information would be great or help would be great...once again my skill set for vb is very limited..

Thanks in advance

kind regards
Updated 22-Nov-11 18:14pm

This is fairly simple to achieve. Split the string at the comma, then remove the IP Address: Host: and Time: portions of the text, saving what's left into your text boxes.

One option to remove them is like this:
replace(VARIABLENAME, "IP Address: ", "")

Edit: Here is an example
Dim infoString As String = "IP Address:, Host: RTR-BIF01,Time: 18:00 GMT"
Dim split As String() = infoString.Split(","c)
txtip.Text = Replace(split(0).Trim(), "IP Address: ", "")
txthost.Text = Replace(split(1).Trim(), "Host: ", "")
txttime.Text = Replace(split(2).Trim(), "Time: ", "")
SIFNOk 23-Nov-11 0:20am
Thanks for the reply..i dont understand how that could work :S
LanFanNinja 23-Nov-11 0:25am
Recheck the solution
LanFanNinja 23-Nov-11 0:25am
+5 I added an example to your solution I hope you don't mind.
_Damian S_ 23-Nov-11 1:27am
No, it's alright... I usually give enough information to let the other person have a crack at it themselves rather than a full solution...
SIFNOk 23-Nov-11 0:32am
Thanks both for your contribution!! I appreciate your replys and help! it has helped me incredibly! doo u have any links for more information on string splitin..or is google the best bet....but thanks again.
LanFanNinja 23-Nov-11 0:35am
Check this Link

Edit: I update my example to show the use of Trim() (to remove any unwanted whitespace)
Use Split method for this
string ss = "IP Address:, Host: RTR-BIF01,Time: 18:00 GMT";
           string[] split = ss.Split(new Char[] { ',' });

           ArrayList al = new ArrayList();

           foreach (string s in split)

               if (s.Trim() != "")

and assign value to text boxes as
al[0].ToString().Replace("IP Address: ", "").ToString();
al[1].ToString().Replace("Host:", "").ToString();
al[2].ToString().Replace("Time:", "").ToString();

Hope now it works
SIFNOk 23-Nov-11 0:27am
Hi Umu

Thanks for the reply...i have converted the code from C# to, but when i try make the array dispay in the still shows "IP Address:" seems to split fine but how can i update the array after i did the replace
LanFanNinja 23-Nov-11 0:29am
Recheck solution 1
uspatel 23-Nov-11 0:34am
Check updated answer
LanFanNinja 23-Nov-11 0:44am
However for this particular string this code
ArrayList al = new ArrayList();
foreach (string s in split)
if (s.Trim() != "")
is not necessary. Just do this i.e.
txtip.Text = Replace(split(0).Trim(), "IP Address: ", ""))
uspatel 23-Nov-11 0:51am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900