Results 1 to 12 of 12

Thread: [RESOLVED] Operator '<<' is not defined for types 'Char' and 'Integer'

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Resolved [RESOLVED] Operator '<<' is not defined for types 'Char' and 'Integer'

    Hey guys, maybe you can help me.

    I am trying to convert a piece of C# code, and I ran it through a converter, and had to make some changes.

    I am now running into this error:

    Operator '<<' is not defined for types 'Char' and 'Integer'


    The code is:

    Code:
    a += CType(URL(k + 0) + (URL(k + 1) << 8) + (URL(k + 2) << 16) + (URL(k + 3) << 24), UInt32)
                b += CType(URL(k + 4) + (URL(k + 5) << 8) + (URL(k + 6) << 16) + (URL(k + 7) << 24), UInt32)
                c += CType(URL(k + 8) + (URL(k + 9) << 8) + (URL(k + 10) << 16) + (URL(k + 11) << 24), UInt32)
    The error occurs on each of the (URL(...) << X)


    Any help would be appreciated.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    Obviously bit-shifting can only possibly work on numbers. If C# appears to be able to do it on Chars then that's because it will implicitly convert the Char to a number. If VB won't do that implicitly then you need to do it explicitly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    Could you throw me an example?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    Google not working round your way?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    Not particularly,

    maybe you could assist me in what exactly to search for.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    All the information you need is in my first post. If you're unable to read simple instructions and extract the keywords from them then you're going to have a lot of trouble with software development. This is a chance to practise and improve that skill. I'm happy to help but I already have.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    Yes jmc, I am clearly incapable of understanding what you are saying in your first post.

    I appreciate the help you do around the forums, and there are things that both you, and I could still learn, and I would appreciate it if you don't imply I am unable to develop for the fact that I don't quite understand your initial response.

    Your message in the first post does not give me a clear "what to search for".

    I am sure that this response will make you not want to help me, so for that, oh well; However, Thanks anyways.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    I actually got it, thanks anyways folks.


    Had to add: AscW before the url(...)

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    scratch that, it got rid of the errors, but it doesnt appear to be working still.

  10. #10

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    If VB won't do that implicitly then you need to do it explicitly
    There's your hint on how to fix the problem. AscW is a VB6 routine anyways, so you need to think of how you can convert a Char to an Integer, or you can Google the method.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: Operator '<<' is not defined for types 'Char' and 'Integer'

    I actually found a PHP for what I wanted to do, and am using that temporarily.

    However, thanks for the insight Formless.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [RESOLVED] Operator '<<' is not defined for types 'Char' and 'Integer'

    PHP?! That's crazy. Just read what I posted for goodness sake:
    If C# appears to be able to do it on Chars then that's because it will implicitly convert the Char to a number. If VB won't do that implicitly then you need to do it explicitly.
    I told you EXACTLY what you need to search for: how to convert a Char to a number in VB. I just Googled vb.net convert char to number and the very first result gave the answer:

    http://forums.asp.net/t/1129741.aspx/1

    I cannot fathom how anyone, save a non-English speaker, could not see that information in my first post. It seems more and more to me that the easier information is to come by the more people expect it to come to them and the less they are prepared to do to go and get it. "Can you provide an example" and "can you provide a link" seem to be the first and second options most of the time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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