Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 17th, 2004, 9:20 PM   #11
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
Ok, here's how the program is supposed to work. I am creating a GUI interface that will allow the user to enter five tests into labeled text boxes which will then store the values in a single dimensional array. I must have 5 values inputed into each of the 5 text boxes for this program or it will display an error. With my code, I am trying to figure out how do I take the numbers inputted into the text box into an array which will then calculate the high, low, average, and print the scores back in the original order. For example, if I put a 90, 92, 69, 77 and 97 into the respective text boxes, what kind of changes do I need to make to my code earlier for it to recognize my inputted text box values so it could calculate what I need? Sorry if I was unclear earlier and I appreciate your help.
mgoku21 is offline   Reply With Quote
Old Nov 17th, 2004, 9:42 PM   #12
Tim_Myth
Newbie
 
Join Date: Nov 2004
Location: Dilworth, MN
Posts: 15
Rep Power: 0 Tim_Myth is on a distinguished road
KISS

Id use pretty colors again, but Pi will just "fix" them for me. To get colors you'll have to c&p this into your IDE. Next time I better RTFM.

First off, if all your scores are integers, dim Highest, Lowest, Total, and A(4) as INTs. No sense hogging resources with decimal types.

Second to get the values from the text box, just use
VAL(txtScore1)
,
val(txtScore2)
, etc. .text is the default property for a textbox, so there's no need to type the extra stuff. This is the only change you should have to make tyo get that code to work.
Tim_Myth is offline   Reply With Quote
Old Nov 17th, 2004, 9:43 PM   #13
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
VB arrays start at 1 not 0
__________________

tempest is offline   Reply With Quote
Old Nov 17th, 2004, 9:55 PM   #14
Tim_Myth
Newbie
 
Join Date: Nov 2004
Location: Dilworth, MN
Posts: 15
Rep Power: 0 Tim_Myth is on a distinguished road
Quote:
Option Base Statement
See Also Example Specifics

Used at module level to declare the default lower bound for array subscripts.

Syntax

Option Base {0 | 1}

Remarks

Because the default base is 0, the Option Base statement is never required. If used, the statement must appear in a module before any procedures. Option Base can appear only once in a module and must precede array declarations that include dimensions.

Note The To clause in the Dim, Private, Public, ReDim, and Static statements provides a more flexible way to control the range of an array's subscripts. However, if you don't explicitly set the lower bound with a To clause, you can use Option Base to change the default lower bound to 1. The base of an array created with the the ParamArray keyword is zero; Option Base does not affect ParamArray (or the Array function, when qualified with the name of its type library, for example VBA.Array).

The Option Base statement only affects the lower bound of arrays in the module where the statement is located.
Second, I just noticed you are trying to access the .TEXT property of the label. Label don't have a text property, they have a caption property. The caption property is the default property for Labels, so you can either get rid of the .TEXT or change it to .CAPTION.
Tim_Myth is offline   Reply With Quote
Old Nov 17th, 2004, 10:03 PM   #15
Tim_Myth
Newbie
 
Join Date: Nov 2004
Location: Dilworth, MN
Posts: 15
Rep Power: 0 Tim_Myth is on a distinguished road
Here is the code that supposedly doesn't work. You may want to examine it to figure out where your errors are.
Tim_Myth is offline   Reply With Quote
Old Nov 17th, 2004, 10:08 PM   #16
Tim_Myth
Newbie
 
Join Date: Nov 2004
Location: Dilworth, MN
Posts: 15
Rep Power: 0 Tim_Myth is on a distinguished road
GRRRRR!!!!!!!!

I Missed the freakin changes that Pi made, so the code is quite flawed. Putting my original code back in results in something that really does work.

Sorry about that. I need to pay attention to "friendly" changes.
Tim_Myth is offline   Reply With Quote
Old Nov 17th, 2004, 10:20 PM   #17
Tim_Myth
Newbie
 
Join Date: Nov 2004
Location: Dilworth, MN
Posts: 15
Rep Power: 0 Tim_Myth is on a distinguished road
Quote:

On a side note the code that Tim_Myth posted for checking for the lowest and highest values is flawed since if the user enters 50, 60, 30, 40, 90 as values in that order, your lowest and highest values will never be set. Even if the user enters 30,40,50,60,70 as inputs high and low values won't be set since:
IF a(X) < Lowest THEN Lowest = a(X)

a(X) will always be larger than the value that Lowest holds. Same thing for the line:
IF a(X) > Highest THEN Highest = a(X)
since a(x) will always be lower, since you can't have a grade above 100% or Below 0%
After declaring variables we set Highest to THE LOWEST SCORE POSSIBLE. Therefore, any score higher than 0 will become the new highest score. If our dataset is

{2,4,3}

our first pass is true and so will result in the following:

If 2 > 0 then Highest = 2

The second is true, so it would be:

If 4 > 2 then Highest = 4

The third pass is false so it is just:

If 3 > 4 then (ignore this because its false)

So, in one pass through the loop we have found our highest number. Reversing the sing (making it a "< " instead of a ">") will let us find the smallest number IF WE SET Lowest to the highest possible value (say 9999 for s&g's). This is because every value possible will be lower than this number. It's really quite simple and shouldn't require a whole page of code to figure out. Don't they teach KISS in school anymore?
Tim_Myth is offline   Reply With Quote
Old Nov 17th, 2004, 10:34 PM   #18
mgoku21
Newbie
 
Join Date: Nov 2004
Posts: 12
Rep Power: 0 mgoku21 is on a distinguished road
I see what you did now Tim. There were some very suprising ways of doing this but in the end I found out what I did wrong. The Val came in handy . Thank you all for your help.
mgoku21 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:34 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC