String Problem, probably very easy...

m-sport

New member
Joined
Dec 30, 2007
Messages
3
Programming Experience
Beginner
Hi!

I would appreciate some help on this string:

shell ("netsh.exe interface ip add address name=""" & TextBox1.Text & """ addr=192.168.254.2 mask=255.255.255.0")

This is all as a single line of code, but when executed, it is line shifted right after the last &, like below:

netsh.exe interface ip add address name="Local Area Connection
" addr=192.168.254.2 mask=255.255.255.0

What am i doing wrong? Because of this , netsh wont work...

Thanx

M-sport
 
Mmm. I'd guess your TextBox string has a trailing carriage return.

Try replacing "TextBox1.Text" with "TextBox1.Text.TrimEnd"
 
You will see strange characters in a single-line Textbox if there are linefeeds in the text. Multiline property defaults to False.
If you're asking how to safeguard yourself from possible "textbox attacks", then another solution is using the Lines string array where each item is one line of text; TxtBx.Lines(0) is first line.
 
Mmm. I'd guess your TextBox string has a trailing carriage return.

Try replacing "TextBox1.Text" with "TextBox1.Text.TrimEnd"

Thanx for reply!

Shell("netsh.exe interface ip add address name=""" & ListBox1.SelectedItem.trimend & """ addr=192.168.254.2 mask=255.255.255.0", AppWinStyle.Hide)

This worked nicely, now i can fetch the NIC name straight from the listbox, instead of moving it to a listbox first :) (I'm new to this :p )
 
Back
Top