Convert C to VB
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Convert C to VB

  1. #1
    Join Date
    May 2011
    Posts
    3

    Convert C to VB

    Please help me,how can i convert this c++ code to vb.

    LPSTR lpszComparison;

    CHAR szzMethod[] = "1000\0" "2000\0" "3000\0";
    pcnd.lpszComparison = szzMethod;


    lpszComparison
    Set a pointer to the buffer containing multiple null-terminated comparison strings. The last string in the buffer must be terminated by two NULL characters

    please show me the convertion of this to VB 6.0

    thank you

  2. #2
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Smile Re: Convert C to VB

    Set a pointer to the buffer containing multiple null-terminated comparison strings. The last string in the buffer must be terminated by two NULL characters
    as much as i know .there is no any concept of pointer in neither in vb nor in vb.net .it is very hard to convert c code in vb .better why don't you write code in vb.net .it is
    much easier language then c ,c++.
    Last edited by firoz.raj; May 31st, 2011 at 09:36 AM.

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,000

    Re: Convert C to VB

    Pretty hard, if you didn't write the DLL, isn't it?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Convert C to VB

    Code:
    LPSTR lpszComparison;
    Search CG for DLL Calling 'Declare Function XXX lib "YYY" (parameters)'
    Code:
    CHAR szzMethod[] = "1000\0" "2000\0" "3000\0";
    hmm this should be something like
    Code:
    Dim szzMethod(2) as String
    szzMethod(0) = "1000\0"
    szzMethod(1) = "2000\0" 
    szzMethod(2) = "3000\0"
    And finaly
    Code:
    pcnd.lpszComparison = szzMethod;
    Look up Calling conventions...
    there are different methods to call this.. one been
    Code:
    Output = lpszComparison (szzMethod())
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,594

    Re: Convert C to VB

    Quote Originally Posted by GremlinSA View Post
    Code:
    CHAR szzMethod[] = "1000\0" "2000\0" "3000\0";
    hmm this should be something like
    Code:
    Dim szzMethod(2) as String
    szzMethod(0) = "1000\0"
    szzMethod(1) = "2000\0" 
    szzMethod(2) = "3000\0"
    I'd say it's rather like

    Code:
      Dim szzMethod As String
      szzMethod = "1000" & Chr(0) & "2000" & Chr(0) & "3000" & Chr(0)
    However, of course this doesn't solve the OP's overall problem...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Convert C to VB

    Quote Originally Posted by Eri523 View Post
    I'd say it's rather like

    Code:
      Dim szzMethod As String
      szzMethod = "1000" & Chr(0) & "2000" & Chr(0) & "3000" & Chr(0)
    However, of course this doesn't solve the OP's overall problem...
    Ahh okay ...

    My C is rusty at best ... And looking at it again your correct.. Array of Char = String...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  7. #7
    Join Date
    May 2011
    Posts
    3

    Re: Convert C to VB

    this is the whole codes from c


    typedef struct tagSORTMETHOD {
    DWORD cbSize; /* Size of SORTMETHOD structure */
    INT32 nPocket;
    INT32 nSortMethod;
    LONG lUseStartPosChar;
    LONG lPos;
    CHAR cStartPos;
    LONG lUseEndPosChar;
    LONG lLen;
    CHAR cEndPos;
    LPSTR lpszComparison;
    BOOL bPolarity;
    } SORTMETHOD, *LPSORTMETHOD;

    pcnd.cbSize = sizeof(SORTMETHOD);
    pcnd.nSortMethod =1;
    pcnd.nPocket=1;
    pcnd.lPos = 0;
    pcnd.lLen = 4;
    CHAR szzMethod[] = "1000\0" "2000\0" "3000\0";
    pcnd.lpszComparison = szzMethod;
    pcnd. bPolarity = TRUE;

    CsdParSet( CSDP_SORT_METHOD, (LPARAM) &pcnd );

    could anyone help me please...

    tnx

  8. #8
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,000

    Re: Convert C to VB

    You can't really use that, as VB6 doesn't know what a POINTER is, and your code uses one.
    Code:
    CHAR cStartPos;
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    May 2011
    Posts
    3

    Re: Convert C to VB

    Guys this is the code from C.NET,please convert it to VB.NET hope this would help.

    Tnx

    public struct SORTMETHOD
    {
    /// <summary>sizeof SORTMETHOD structure</summary>
    public int cbSize;
    /// <summary></summary>
    public int nPocket;
    /// <summary></summary>
    public int nSortMethod;
    /// <summary></summary>
    public int lUseStartPosChar;
    /// <summary></summary>
    public int lPos;
    /// <summary></summary>
    public char cStartPos;
    /// <summary></summary>
    public int lUseEndPosChar;
    /// <summary></summary>
    public int lLen;
    /// <summary></summary>
    public char cEndPos;
    /// <summary></summary>
    [MarshalAs(UnmanagedType.LPStr)]
    public string lpszComparison;
    /// <summary></summary>
    [MarshalAs(UnmanagedType.Bool)]
    public bool bPolarity;
    }

  10. #10
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,000

    Re: Convert C to VB

    Here's the first line, so you can see the SYNTAX
    Code:
    Public cbSize as Integer ' or whatever TYPE it is
    Also, please use CODE TAGS
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center