Results 1 to 9 of 9

Thread: Type expected error!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    Angry 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!

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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)

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    Re: Type expected error!

    I want it to set textbox1.text to whatever page you are on!

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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:
    Name:  Designer.PNG
Views: 325
Size:  7.9 KBName:  Form1.PNG
Views: 240
Size:  44.0 KB

  9. #9
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width