Forum Moderators: open

Message Too Old, No Replies

Getting a link label value from text box

vb.net

         

mack

9:40 am on Apr 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I am trying to have a link label in a Windows form that opens a web browser to a specific page but adds a query to the url taken from a text box.

When the form loads the textbox already has a value "test" how lets assume I was sending the query to example.com and adding the?q=test to the url...

www.example.com?q=test

I am using the following code...


Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked

System.Diagnostics.Process.Start("http://www.example.com?q=(txtbox1.text)")
End Sub

I appear to have my syntax wrong, any suggestions.

When clicked it opens http://www.example.com?q=(txtbox1.text)

Thanks in advance.

Mack.

johnhh

1:19 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



everything within a " and a " is a literal you need to add the variable object to the base string such as

"q=" & txtbox1.text

mack

6:47 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi johnhh, thanks for your reply.

I am pretty new to vb.net to a little yellow when it comes to it. :)

Should I store the value of my query in an array then add it to the end of the url.

The url will always be the same so that part can be hard coded into the app, the only part that will change will be the query. The query will be extracted from the textbox.

Mack.

mack

10:08 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



hehe it was just me being slow....


Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked

System.Diagnostics.Process.Start("http://www.example.com?q=" & txtbox1.Text)
End Sub

Thanks again :)

Mack.

johnhh

10:19 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Mack

array a bit over the top -unles you have another reason

try
System.Diagnostics.Process.Start("http://www.example.com?q=" & txtbox1.text)

of course you could also use, hopefully

varNew="http://www.example.com?q=" & txtbox1.text
System.Diagnostics.Process.Start (varNew)

you also need a check to see if txtbox1.text is empty

ASP man myself but very close enough to vb.net!

then you should be able to read the variable on the next page by using request.querystring.

hope that helps

mack

9:55 am on Apr 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Many thanks again, Used your method and now working fine.

Mack.