Custom function

Discussion in 'Questions (Windows Mobile)' started by go4saint, Apr 8, 2008.

Thread Status:
Not open for further replies.
  1. go4saint

    go4saint Guest

    Hi,

    Is there a way to create a custom function, like in Excel VBA ?
    For example a function to multiply two numbers,

    =multiply(a,b)

    where a and b are 2 text boxes on a form.

    If anyone can give me an example, I will understand better and try to create my own functions.

    Thanks!
     
    Last edited by a moderator: Apr 8, 2008
  2. klaus

    klaus Expert Licensed User

    Yes you can !

    I have added a small example that shows a solution.

    Code:
    Sub Globals
    'Declare the global variables here.
       c=0
    End Sub

    Sub App_Start
       Form1.Show
    End Sub

    Sub Multiply(a,b)
       
    Return a*b
    End Sub

    Sub Button1_Click
       c=Multiply(TextBox1.Text,TextBox2.Text)
       Label1.Text=c
    End Sub
    You can of course use other intermediate variables for the values in the textboxes.

    Best regards
     
  3. go4saint

    go4saint Guest

    Thanks a lot!
     
  4. go4saint

    go4saint Guest

    Thanks for solution klaus,

    but there is a problem when I try to compile in both Desktop and Device.

    Error Message CS1525:Invalid expression term ')'
    in line c=Multiply(TextBox1.Text,TextBox2.Text)
     
  5. specci48

    specci48 Well-Known Member Licensed User

    Hm... there must be a typo or something like that in your personal code because the sample of klaus works fine. Take his attachment and try to compile it, it will work. So I'm sure you implemented his solution manually into your own code.

    Error CS1525 occurs when the compiler detects an invalid character in an expression, so have a close look to you code again.


    specci48
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Thats because you are using a hacked version of Basic4ppc.
     
Thread Status:
Not open for further replies.
Loading...