| Welcome to The New Coffee Room. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Visual Basic | |
|---|---|
| Tweet Topic Started: Jan 10 2008, 09:04 PM (188 Views) | |
| Riley | Jan 10 2008, 09:04 PM Post #1 |
|
HOLY CARP!!!
|
How would I get this program to give me the actual high and low numbers from the list generated, rather than '1' and '10', as the LBound and UBound functions give?![]() Option Explicit Dim strNumbers(1 To 10) As String Dim lngIndex As Long Sub Numbers() strNumbers(1) = Int(99 * Rnd + 1) strNumbers(2) = Int(99 * Rnd + 1) strNumbers(3) = Int(99 * Rnd + 1) strNumbers(4) = Int(99 * Rnd + 1) strNumbers(5) = Int(99 * Rnd + 1) strNumbers(6) = Int(99 * Rnd + 1) strNumbers(7) = Int(99 * Rnd + 1) strNumbers(8) = Int(99 * Rnd + 1) strNumbers(9) = Int(99 * Rnd + 1) strNumbers(10) = Int(99 * Rnd + 1) Dim lngIndex As Long For lngIndex = LBound(strNumbers) To UBound(strNumbers) lstNumbers.AddItem strNumbers(lngIndex) Next lngIndex End Sub Private Sub cmdDone_Click() Unload frmMaxandMin End Sub Private Sub cmdMax_Click() lblAnswer.Caption = "Max Number = " & UBound(strNumbers) End Sub Private Sub cmdMin_Click() lblAnswer.Caption = "Min Number = " & LBound(strNumbers) End Sub Private Sub Form_Load() Randomize Call Numbers End Sub |
![]() |
|
| Klaus | Jan 11 2008, 02:55 AM Post #2 |
![]()
HOLY CARP!!!
|
Either there is a library function that computes max/min of a list of numbers, or you have to do it by hand by iterating over the list. It is a bit messy that the numbers in strNumbers are stored as strings, though. |
| Trifonov Fleisher Klaus Sokolov Zimmerman | |
![]() |
|
| Mikhailoh | Jan 11 2008, 04:58 AM Post #3 |
|
If you want trouble, find yourself a redhead
|
Can't you do an integer array in VB? |
|
Once in his life, every man is entitled to fall madly in love with a gorgeous redhead - Lucille Ball | |
![]() |
|
| Copper | Jan 11 2008, 07:43 AM Post #4 |
|
Shortstop
|
This is kind of overkill for you problem, but this is a nice way to do it if you are dealing with more data: http://msdn2.microsoft.com/en-us/library/s...ylist.sort.aspx The example is here: http://msdn2.microsoft.com/en-us/library/8k6e334t.aspx |
|
The Confederate soldier was peculiar in that he was ever ready to fight, but never ready to submit to the routine duty and discipline of the camp or the march. The soldiers were determined to be soldiers after their own notions, and do their duty, for the love of it, as they thought best. Carlton McCarthy | |
![]() |
|
| Copper | Jan 11 2008, 07:46 AM Post #5 |
|
Shortstop
|
Actually now that I look at it, it is simple. I thought this was the example with the "CompareTo" method which is more complex, but still a nice way to sort. |
|
The Confederate soldier was peculiar in that he was ever ready to fight, but never ready to submit to the routine duty and discipline of the camp or the march. The soldiers were determined to be soldiers after their own notions, and do their duty, for the love of it, as they thought best. Carlton McCarthy | |
![]() |
|
| Moonbat | Jan 11 2008, 07:50 AM Post #6 |
![]()
Pisa-Carp
|
Yuck what a hideous language VB is. (though maybe i only think that because i don't use it). |
| Entia non sunt multiplicanda praeter necessitatem | |
![]() |
|
| Copper | Jan 11 2008, 07:52 AM Post #7 |
|
Shortstop
|
Yup. I'm mostly C# now so I see a lot of VB since the 2 come from the same factory. Of course 370 assembler language is still the king. |
|
The Confederate soldier was peculiar in that he was ever ready to fight, but never ready to submit to the routine duty and discipline of the camp or the march. The soldiers were determined to be soldiers after their own notions, and do their duty, for the love of it, as they thought best. Carlton McCarthy | |
![]() |
|
| Aqua Letifer | Jan 11 2008, 07:53 AM Post #8 |
|
ZOOOOOM!
|
Nahh, it's fine for what it's used for, which are fairly simple computations. |
| I cite irreconcilable differences. | |
![]() |
|
| Klaus | Jan 11 2008, 08:23 AM Post #9 |
![]()
HOLY CARP!!!
|
Just to add to the confusion, here is what the DIY solution looks like in Haskell:
|
| Trifonov Fleisher Klaus Sokolov Zimmerman | |
![]() |
|
| « Previous Topic · The New Coffee Room · Next Topic » |









4:34 PM Jul 10