visual basic programming string command prob

Microsoft Windows xp professional w/serv...
December 4, 2010 at 15:12:03
Specs: Windows XP, 514 MB of RAM
How do I use this command? Well.... I can not get the command right, and I can not remember it... here is what I have.Dim textbox2.text = as string I need to know what the command is because I have it wrong... what im doing is I am trying to turn the text in "textbox2.text" in to a string... PLZ HELP ASAP

Do something when your doing nothing.


See More: visual basic programming string command prob

Report •

#1
December 4, 2010 at 15:38:44
UPDATE: I am trying to change the properties in the web browsers URL (Home page) and here is the code... the full code...
Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
Form1.WebBrowser1.Navigate(TextBox2.Text)
Dim textbox2.text = as string
Form1.WebBrowser1.Url = (TextBox2.text)
End Sub
The error I get is when I put my mouse over (textBox2.text)is: "Value type of string can not be converted to system.uri." so I did the as string thing.... All I need is that error message to stop and work right so forget about the as string thing Just need no errors

Do something when your doing nothing.


Report •

#2
December 4, 2010 at 16:20:41
You cannot Dimension a text box as a string. Textboxes are strings by default, the cannot be anything else. They can be converted to other data types but they always start of as strings.

You only dim a variable which can be anything from a string to to a floating point number.

Stuart


Report •

#3
December 4, 2010 at 19:51:43
1) It's "you're," not "your"
2) Your signature is annoying.

Fix those two problems, and I'll tell you what you should do.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
December 6, 2010 at 10:00:30
Ok... New signature. Now, may you please help me now?:(

Computers are needed forever.


Report •

#5
December 6, 2010 at 11:08:00
Okay then.

WebBrowser.Url expects a URI object, and converting a String to URI can throw a UriFormatException.

A much easier way to do just use WebBrowser.Navigate.

WebBrowser1.Navigate(TextBox2.Text)

But if you insist in setting the Url property, at a bare minimum, you need the following code:
Try
  WebBrowser1.Url = New Uri(TextBox2.Text)
Catch ex As UriFormatException
  'Handle error
  MsgBox("Bad URI. Try again.", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "ERROR")
End Try

How To Ask Questions The Smart Way


Report •

#6
December 7, 2010 at 10:41:55
Thank you very much, exept now I have another problem... (Sorry, I just started programming on my own 5 days ago) When I click my homepage button it just refreshes the page... this is my code: webbrowser1.navigate (webbrowser1.url) May you please help?

Computers are needed forever.


Report •

#7
December 7, 2010 at 19:02:06
Think about what you're actually telling the program to do. You're telling your WebBrowser object to go to the address it's already at. This refreshes the page. If that's not what you want, you'll need to think about how to tell the program your intentions.

How To Ask Questions The Smart Way


Report •

#8
December 8, 2010 at 10:34:33
Thank you for the logic!!! That helped a lot! My home page button and my change home page button works now! But one more question..... Is there a way to save the homepage for the next time I start the program? Sorry for the questions...

Report •

#9
December 8, 2010 at 15:42:28

Report •

Ask Question