Announcement

Collapse
No announcement yet.

Multiplication (Inside a Sub/Function)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Semen Matusovski
    replied
    Ian --
    Zdravctyte ?
    I'm afraid that now time to say "do swidanija" (good-bye)
    Now is 2:15am.

    BTW. What happened with a server watch ?
    40 minutes difference looks more than strange.
    Ten years ago Baltic guys decided to move their watches at 0,5h to show an independence from Moscow (time).
    USA also don't like Greenwich (Britain colonialists)?

    [This message has been edited by Semen Matusovski (edited January 05, 2001).]

    Leave a comment:


  • Ian Cairns
    replied
    You have to declare your function (prototype it) before it is used.

    Code:
    #COMPILE EXE
    #INCLUDE "Win32Api.Inc"
    DECLARE FUNCTION MultiplyDwords(Var1 AS DWORD, Var2 AS DWORD) AS DWORD
    
    FUNCTION PBMAIN
      STATIC Var1      AS DWORD, _
             Var2      AS DWORD, _
             VarResult AS DWORD
    
      Var1 = 2345
      Var2 = 5678
      VarResult = MultiplyDwords(Var1, Var2)
      MSGBOX "Multiplied Variable 1 (" + FORMAT$(Var1) + ") with Variable 2 (" + FORMAT$(Var2) + ")" + CHR$(13) + _
              "Resulting in: " + FORMAT$(VarResult)
    
    END FUNCTION
    FUNCTION MultiplyDwords(Var1 AS DWORD, Var2 AS DWORD) AS DWORD
      FUNCTION = Var1 * Var2
    END FUNCTION
    Regards,

    (PS. Boy Semen, you are fast. I'll have to recheck before posting
    next time.(Zdravctyte) )
    ------------------
    [email protected]

    [This message has been edited by Ian Cairns (edited January 05, 2001).]

    Leave a comment:


  • Semen Matusovski
    replied
    Mark --
    Can't understand ...
    Syntax is similar other lang.

    Code:
       #Compile Exe
       #Dim All
       
       Function MultDword(a As Dword, b As Dword) As Dword
          Function = a * b
       End Function
       
       Sub MultDwordS(a As Dword, b As Dword, c As Dword)
          c = a * b
       End Sub
       
       Function PbMain
       
          Dim p1 As Dword, p2 As Dword, p3 As Dword
          
          p1 = 10: p2 = 20: p3 = MultDword (p1, p2): MsgBox Str$(p3)
          p1 = 15: p2 = 25: MultDwordS p1, p2, p3: MsgBox Str$(p3)
    
       End Function
    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • mark pruitt
    started a topic Multiplication (Inside a Sub/Function)

    Multiplication (Inside a Sub/Function)

    I just recently switch to Windows programming from DOS, and I
    hate to sound like such a Newbie, but....

    Can someone give me an example of how to multiply 2 DWORD
    variables inside of a sub or function, and store the result in
    a third DWORD variable? I tried declaring GLOBAL variables
    and then multiplying them inside of a sub or function, and
    I even tried to declare a function, dim the variables inside
    of it, and then multiply them. At compile time, I always
    get error 462 or 477. Help!

    ------------------
Working...
X