Results 1 to 5 of 5

Thread: Cpp Question (translate code VB - VCPP)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Cpp Question (translate code VB - VCPP)

    Greetings,

    would you please so kind and translate this piece of VB code to a VCPP version.

    Many thanks in advance.

    Public Sub gAddProgress()

    Static stintCounter As Integer
    Static stblnFlag As Boolean

    If stblnFlag = False Then
    stintCounter = 1
    stblnFlag = True
    Else
    Call AddOne(stintCounter)
    End If

    End Sub

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Smile Info.

    Try this... There is a remote chance it may work...
    Code:
    //Definition
    void gAddProgress();
    
    
    //Implementation
    void gAddProgress()
    {
        static int stintCounter;
        static bool stblnFlag;
    
        if (stblnFlag == false)
        {
            stintCounter = 1;
            stblnFlag = true;
        }
        else
        {
            //Make sure your AddOne function is defined...
            AddOne(stintCounter);
        }
    }
    Hope this helps.
    Digital-X-Treme
    Contact me on MSN Messenger: [email protected]

    [VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
    / (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use a short rather than an int, because Integer in VB is only 2 bytes but an int in 32-bit C and C++ is 4 bytes.

    Minor quibble I know, but best to be accurate
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And the more common method of testing a bool is
    if(bFlag)
    // true

    if(!bFlag)
    // false

    AddOne needs this prototype
    void AddOne(short& s);
    Which is the translation of Vb
    Public Sub AddOne(ByRef s as Integer)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    Thanks for your help

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