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.

On of my "stupiest" questions....

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-30-2007, 05:49 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default On of my "stupiest" questions....

Hi all,

I'm trying to come up with a simple calcutation tool for an on-line game called travian...
I'm trying to automatiza the calculation of the time nned to travel from point a to b at a given speed...
For the ones not fammyliarized with the game,,, The units have diferents seepds, measured in squares per hour...

So, since I don't want to repeat the same code over and over, I thought about creating a calculation sub and pass the parameters...
But they are not being passed...
I just can't fugure out...

Code:
.....
n=VLeg
Calculos(d,ds,fx,n)
Msgbox(TS)
End Sub

Sub Calculos
v=
3600/n
Msgbox(v)
TS=(v*d)+((v*fx)*ds)
Format(TS,
"n2")
Return(TS)
End Sub
Any thoughts?

I'm also trying to convert seconds to the time format (HH:MM:SS), any one have done that yet?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #2 (permalink)  
Old 11-30-2007, 06:44 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

Hi Cableguy,

since we have local variables, you have to define the parameters in the called sub again:

Sub Calculos(d,ds,fx,n)
...
End Sub


Cheers
specci48


PS: There is no stupid question, there are only stupid answers...
Reply With Quote
  #3 (permalink)  
Old 11-30-2007, 06:46 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by specci48 View Post
Hi Cableguy,

since we have local variables, you have to define the parameters in the called sub again:

Sub Calculos(d,ds,fx,n)
...
End Sub


Cheers
specci48
I knew I was forgetting something....dahm....

Thnks Specci...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #4 (permalink)  
Old 11-30-2007, 06:51 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Ok, so calculations now occur but the TS var is not returned to the calling sub....Any thoughts????
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #5 (permalink)  
Old 11-30-2007, 06:56 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

... I forgot to answer to your second question.

If you want to convert seconds to HH:MM:SS you can do something like this.

Code:
TimeFormat("HH:mm:ss")
Label1.Text = Time(seconds * cTicksPerSecond)
This works for 0 =< seconds < 86400 since 86400 seconds equals 00:00:00 again.


specci48
Reply With Quote
  #6 (permalink)  
Old 11-30-2007, 06:58 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

... since we have local variables, you have to assign the returning value to a variable...

TS = Calculos(d,ds,fx,n)

Last edited by specci48 : 11-30-2007 at 07:01 PM.
Reply With Quote
  #7 (permalink)  
Old 11-30-2007, 07:18 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Quote:
Originally Posted by specci48 View Post
... since we have local variables, you have to assign the returning value to a variable...

TS = Calculos(d,ds,fx,n)
That doesn't work since TS is tne result of a mathematical expression....
Still in the help file it reads:
Quote:

Return

--------------------------------------------------------------------------------

Ends the current sub and returns to the calling sub.
If Return is followed by a value, then the value will be passed to the calling sub.
Syntax: Return [Value]


Example:
Sub Button1_Click
If IsInteger (a) = true Then b=a
End Sub


Sub IsInteger (x)
If x = Int(x) Then Return true Else Return false
End Sub
So the code SHOULD work but it gives an "input in the wrong format" kind of error...

Solved:the paramters returned do not need to be inside brackets.....
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!

Last edited by Cableguy : 11-30-2007 at 07:21 PM. Reason: found my error...
Reply With Quote
  #8 (permalink)  
Old 11-30-2007, 07:22 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

Quote:
Originally Posted by Cableguy View Post
... but it gives an "input in the wrong format" kind of error...
Remove the brackets from the return statement
Code:
Return TS
Edit:
oops ... missed your edit ...

Last edited by specci48 : 11-30-2007 at 07:24 PM.
Reply With Quote
  #9 (permalink)  
Old 12-01-2007, 01:44 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Ok, back to the same stupid question:

I have in one sub....

TS= some mathematical operation
MsgBox(TS) ' Does show the result from the previous line...
Return TS ' Nothing is passed to the calling sub, WHY????
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #10 (permalink)  
Old 12-01-2007, 01:55 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

Can you post how the code looks like at the monent?

Edit: Have you implemented post #6 in your calling sub?

Last edited by specci48 : 12-01-2007 at 02:08 PM.
Reply With Quote
Reply


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
"AddEvent" and "buttonUp/buttonDown" Byak@ Questions (Windows Mobile) 12 09-10-2008 03:04 PM
Neuling bei Basic4ppc - wollte mal "Hallo" sagen ... JOTHA German Forum 49 08-28-2008 11:59 PM
Is there any thing like Visual Basic "Tabbed dialog control" in Basic4ppc? mozaharul Questions (Windows Mobile) 6 03-23-2008 11:07 AM
Image Button kommt nicht wieder "hoch" troll German Forum 3 02-22-2008 09:03 AM
calling the device's "Programs" or "settings" screens HarleyM Questions (Windows Mobile) 0 12-05-2007 02:59 AM


All times are GMT. The time now is 05:58 AM.


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