Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Custom function

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-08-2008, 02:16 PM
go4saint
Guest
 
Posts: n/a
Default Custom function

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 go4saint : 04-08-2008 at 02:18 PM.
  #2 (permalink)  
Old 04-08-2008, 02:51 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
  #3 (permalink)  
Old 04-08-2008, 03:11 PM
go4saint
Guest
 
Posts: n/a
Default

Thanks a lot!
  #4 (permalink)  
Old 04-08-2008, 07:06 PM
go4saint
Guest
 
Posts: n/a
Default

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 (permalink)  
Old 04-08-2008, 07:19 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

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 (permalink)  
Old 04-08-2008, 07:24 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Thats because you are using a hacked version of Basic4ppc.
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
QuickSMS - Define your own custom speed send messages and send them quickly! Oran Share Your Creations 3 03-06-2009 06:05 AM
Custom contact list Dinis Questions (Windows Mobile) 9 08-31-2008 11:18 AM
Function Key eillezcas Questions (Windows Mobile) 0 08-27-2008 08:28 PM
Exp() function Bruno Questions (Windows Mobile) 5 06-05-2008 07:03 PM
C# Custom control creation Cableguy Questions (Windows Mobile) 2 05-19-2008 01:04 PM


All times are GMT. The time now is 09:12 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0