string manipulation

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I am running vs 2005 and withing vb I have code that will lookup dns and
will give me the host name back, but I need to truncate the host name and
have it populate into a text box on a form.

The code brings back netbiosname.domain.com

I want to be able to truncate it to show netbiosname only and populate it
into a textbox within a form.
 
HI Mike
Here is a way to do it:

Dim str As String = "netbiosname.domain.com" 'Replace this with what is
returned by the code
TextBox1.Text = str.Substring(0, str.IndexOf("."))
Regards
Parag
 
I am running vs 2005 and withing vb I have code that will lookup dns and
will give me the host name back, but I need to truncate the host name and
have it populate into a text box on a form.

The code brings back netbiosname.domain.com

I want to be able to truncate it to show netbiosname only and populate it
into a textbox within a form.

dim sFullName as String = "netbiosname.domain.com"
dim sHostName as String

sHostName = sFullName.Substring(0, sFullName.IndexOf(".") )
 
"Mike" <[email protected]>'s wild thoughts were
released on Wed, 4 Apr 2007 10:59:53 -0400 bearing the
following fruit:
I am running vs 2005 and withing vb I have code that will lookup dns and
will give me the host name back, but I need to truncate the host name and
have it populate into a text box on a form.

The code brings back netbiosname.domain.com

I want to be able to truncate it to show netbiosname only and populate it
into a textbox within a form.

Take a look at Split() althought there are many ways to
achive your goal.
 
or of course

stick it in SQL Server and use ParseName in order to navigate back
through particular nodes.

for example-- I used this for walking through various nodes of an IP
Address

Select ParseName('192.168.4.1', 1) = 192
Select ParseName('192.168.4.1', 2) = 168
Select ParseName('192.168.4.1', 3) = 4
Select ParseName('192.168.4.1', 4) = 1

or something along those lines

that function is designed for something else-- but it works quite well
for parsing on periods-- worse comes to worse use the reverse function
first LoL
 
(e-mail address removed) schreef:
or of course

stick it in SQL Server and use ParseName in order to navigate back
through particular nodes.

for example-- I used this for walking through various nodes of an IP
Address

Select ParseName('192.168.4.1', 1) = 192
Select ParseName('192.168.4.1', 2) = 168
Select ParseName('192.168.4.1', 3) = 4
Select ParseName('192.168.4.1', 4) = 1

or something along those lines

that function is designed for something else-- but it works quite well
for parsing on periods-- worse comes to worse use the reverse function
first LoL

No need to use SQL for this. Use the string.split function.
i.e.:

str.split(".")(1) will return "domain" in your this case.
 
Back
Top