Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. String from vb to VC

String from vb to VC

Scheduled Pinned Locked Moved Visual Basic
helpc++graphicstutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SiddharthAtw
    wrote on last edited by
    #1

    Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

    J M D 3 Replies Last reply
    0
    • S SiddharthAtw

      Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

      J Offline
      J Offline
      John Kuhn
      wrote on last edited by
      #2

      Where are we? VB6? VB.NET? Are you using Declare to initialize the DLL function call in VB6? Or is this VB.NET? More specific code examples? Also, for the c++ code, you might try the c++ forum. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

      S 1 Reply Last reply
      0
      • S SiddharthAtw

        Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

        M Offline
        M Offline
        Matthew Hazlett
        wrote on last edited by
        #3

        First think that comes to mind is you may have to null terminate the string before you send it over. myString &= chr(0) Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure...

        1 Reply Last reply
        0
        • S SiddharthAtw

          Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          VB6 uses BSTR type strings. Which are always Unicode and have their length as the first 4 bytes. When you pass a string to the API ByVal, a copy of the string is automatically made in ASCII (I think!) and a pointer to the copy is actually passed to the function you called. There is no way to "convert" a BSTR into a wString at the function declaration. Either your VB code has to pass the data, NOT necessarily as a String type, to the function in a format the function can deal with, like an array of Bytes that LOOKS like a string, or your function must be able to deal with BSTR's. RageInTheMachine9532

          1 Reply Last reply
          0
          • J John Kuhn

            Where are we? VB6? VB.NET? Are you using Declare to initialize the DLL function call in VB6? Or is this VB.NET? More specific code examples? Also, for the c++ code, you might try the c++ forum. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

            S Offline
            S Offline
            SiddharthAtw
            wrote on last edited by
            #5

            Please don't preach. U know it tell and make me thankful or keep your arse away.

            D J 2 Replies Last reply
            0
            • S SiddharthAtw

              Please don't preach. U know it tell and make me thankful or keep your arse away.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Excuse me! He didn't preach anything. He asked you a couple of valid questions about information that you didn't provide in your initial post. Information that is VITAL to answering your question correctly. Keep his 'arse' away??!!??!! It's responses like this that make me question why ... nevermind... You can bet that I won't be helping you anymore. Be nice to the people your asking for help from! RageInTheMachine9532

              1 Reply Last reply
              0
              • S SiddharthAtw

                Please don't preach. U know it tell and make me thankful or keep your arse away.

                J Offline
                J Offline
                John Kuhn
                wrote on last edited by
                #7

                :confused: Yes, perhaps you misinterpreted my inquiry --- and the reference to the c++ forum was a simple suggestion. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups