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

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

Share Your Creations Show your developed application to Basic4ppc community. Please include source code if possible.

Australian Golf Handicap Calculator

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2010, 11:37 AM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default Australian Golf Handicap Calculator

Golf Australia is moving towards using the USGA system.

As of last February it is no longer possible to calculate your new handicap using just your old one and you latest score. You need to know your last 20 scores.

This program allows you to manage these scores and calculate your new handicap straight after your round. You can even download your last 20 scores direct from golflink or from a saved file.

This program needs a lot more work in terms of data validation and help screens and documentation.

Since the USGA system is similar, though more complicated (because of the slope concept) I will be making a USGA (GHIN) calculator in a month or two.

Cheers
Nick

Last edited by nm7s9 : 06-30-2010 at 02:44 AM. Reason: update zip
Reply With Quote
  #2 (permalink)  
Old 06-29-2010, 09:59 AM
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

Hi Nick,
I had a look at your program even I know nothing about golf.
You could reduce the number of code lines form 944 to 712 in wireing click events of numerous buttons to one subroutine.
I also simplyfied the Calc_rounds_to_use routine.
Attached a modified version.

In routine RadioBtn1_Click , what are the 2 last lines supposed to do.
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Sub </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">RadioBtn1_Click</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">  If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> played_to_plus = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">True </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    radiobtn1.Checked = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">False</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    played_to_plus = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">False</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    tmppto = </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Abs</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(pto.Value)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">  Else</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    radiobtn1.Checked = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">True</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    played_to_plus = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">True</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">    tmppto = </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Abs</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(pto.Value) * (-</font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">1</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">  End </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">  pto.Value = </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Abs</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(tmppto) + </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">1</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">  pto.Value = </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Abs</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(tmppto) - </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">1</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
I think they should be in the If-Then-Else parts

Best regards.
Attached Files
File Type: sbp aushcap_New.sbp (23.1 KB, 10 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #3 (permalink)  
Old 06-29-2010, 11:41 AM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

Many thanks Klaus for your help.

I had already reduced the code by many hundreds of lines when I realised that I could use dynamic controls, but I missed seeing how to to use them on the these buttons. I'll use you version right away.

As to those two strange lines. These were just my clumsly effort to make sure that the pto.ValueChanged event fired.

My calculations all rerovle around a "played to" value being entered. If the plus key is checked then the value is displayed in red but stored as negative and the calculations immediatly redone,

If a gross score or stableford score or par score is entered, then a "played to" value is calculated using handicap and course par and rating and then the calculations are redone. The first time a new "played to" is entered, it is added at the front of the 20 entries and the last one is dropped off. After that any new valuse just overwrite the first entry. (i.e you are correcting the entry or trying out other valuse to see what would have happened if you played better or worse).

Ok so if a "played to" is entered directly then I want to execute pto.ValuedChanged code, but I also want this execute this code if gross,stableford or par scores are entered or if the pto value is turned negative by the plus key. I acheived this just by making sure the value of pto changed.

Is there a nicer way to schedule this event from another subroutine and maybe do "Do Events"? I'm sure it's just as simple as

pto_ValueChanged = true
Do Events

Do I need the "Do Events"?

Cheers
Nick
Reply With Quote
  #4 (permalink)  
Old 06-29-2010, 12:40 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

Now I understand what you want to do with the 2 lines in the RadioBtn1_Click routine.
You can replace those 2 lines simply by pto_ValueChanged.
pto_ValueChanged is a subroutine like any other and you can call it from anywhere in the program (module).

This line
pto_ValueChanged = True
would be wrong because pto_ValueChanged is a routine and not a variable, and no need for DoEvents.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #5 (permalink)  
Old 06-30-2010, 02:52 AM
Junior Member
 
Join Date: Jul 2008
Posts: 37
Default

Thanks Klaus,

The program is looking a little better now - zip updated. (I also had to alter line68 from j = 0 to 5 to be j = 1 to 5 so that my 00 button still zeros out any value currently accumulated.)

When I get back from holidays .I'll try to streamline some more of the code (I threw it together fairly quickly and know that there are a lot of improvements in the code that I can make (maybe even some commentds)

Nick
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
Golf Score and GPS Program - StrokeBusta corwinckler Open Source Projects 0 12-11-2009 08:13 AM
Another Calculator ceaser Share Your Creations 3 07-17-2009 04:20 PM
Probability Calculator dlfallen Share Your Creations 14 06-17-2009 01:34 PM
B4P-Calculator Filippo German Forum 13 01-26-2009 07:52 PM
Another Calculator tremara1 Share Your Creations 1 12-07-2008 04:00 PM


All times are GMT. The time now is 12:35 PM.


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