-
Jan 1st, 2013, 08:23 PM
#1
Thread Starter
New Member
Type expected error!
Hi everyone!
Im trying to make a webbrowser and I have a Type Expected error and it wont go away. What i want this code to do is go to the website, then set toolstriptextbox1.text into the value of webbrowser.url.
Here is my code:
Private Sub ToolStripButton4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
ToolStripTextBox1.Text = (CType (TabControl1.SelectedTab.Controls,(WebBrowser.URL)) 'It happens at the first bracket around Webbrowser.url'
(toolstripbutton4 is the 'go' button)
(also the webbrowser is in a tab with a add tab option)
Thanks!
-
Jan 2nd, 2013, 12:38 AM
#2
Re: Type expected error!
think about it... CType takes two parameters... right? The first being the Object you want to re-type... and the second is the type you want to cast it to... you got it right in the line just before...
-tg
-
Jan 3rd, 2013, 05:06 PM
#3
Thread Starter
New Member
Re: Type expected error!
That doesnt really help, but i changed it and same error.
Here is the modified code.
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
CType(TabControl1.SelectedTab.Controls,'RIGHT HERE'(WebBrowser.locationURL)) = (ToolStripTextBox1.Text)
-
Jan 3rd, 2013, 05:07 PM
#4
Thread Starter
New Member
Re: Type expected error!
I also tried this:
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
CType(TabControl1.SelectedTab.Controls,)(WebBrowser.URL)) = (ToolStripTextBox1.Text)
Same thing though
-
Jan 3rd, 2013, 11:38 PM
#5
Re: Type expected error!
sigh... ok... looks like I need to pull out the trout... and then fix it myself....
Once again... CType takes TWO parameters... the object to type AND THE TYPE ITSELF.... WebBrowser.URL [u]is not a type[/i] ... WebBrowser IS a type ... .URL is a property... understand?
You go it right on this line:
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
So why suddenly deviate from that on the very next line?
CType(TabControl1.SelectedTab.Controls,)(WebBrowser.URL)) = (ToolStripTextBox1.Text)
1) you're now missing the type
2) you're trying to set the property, but you're not accessing it right...
[trout_slap]
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).URL = ToolStripTextBox1.Text
[/trout_slap]
That said... you really should be declaring a variable of type WebBrowser, setting it to the control, and then accessing everything through the variable... it's going to be a lot easier and more efficient than repeatedly CTyping the control.
-tg
-
Jan 4th, 2013, 07:38 AM
#6
Re: Type expected error!
Question: What are you trying to do with this:
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).URL = ToolStripTextBox1.Text
????
If you're using the .Navigate method, there's no reason to set the URL property... it will be set as part of the Navigate process.... or did you really mean to do this?
ToolStripTextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).URL
-tg
-
Jan 9th, 2013, 05:28 PM
#7
Thread Starter
New Member
Re: Type expected error!
I want it to set textbox1.text to whatever page you are on!
-
Jan 9th, 2013, 05:36 PM
#8
Thread Starter
New Member
Re: Type expected error!
I tried what techgnome said but it didnt work. Now it says: Value of 'String' cannot be converted to 'System.URI'.
Here is my designer and scripts:
-
Jan 10th, 2013, 08:19 AM
#9
Re: Type expected error!
I've thought long and hard on how to respond to this... because quite frankly my initial reaction was one that could quite possibly get me banned from here for a couple months...
Instead I'm going to make two comments, then I'm done with this thread.
1) since you are using the value in the textbox to navigate the webbrowser... why would you want to reset it back to the same value?
2) Think about the line with the blue squiggle... there are two things wrong with it... 1) your assignment is backwards... I tried to point this out in post #6 you either ignored it or simply refused to listen. It's a simple variable assignment... you're trying to do this: 15 = x .... that just doesn't work. 2) every object inherits from the base object class... funny thing about the base object class... it has a ToString method... guess what it does?
I get the feeling you're just flailing about and not really understanding what you're doing. Nor do you seem to care about what you're doing, because you've flubbed up some of the most basic things, even when I can see that you get it right in other areas.
I can only come to one of two conclusions... and the other is that this is a joke.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|