![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I think what you are looking for is "InputBox" functionality...?
How about using a counter....? Quote:
Sorry cant really answer more unless you post an example of what you have so far so I can understand better. Last edited by badkarma : 04-12-2008 at 11:54 AM. |
|
||||
|
You should not use a loop here.
I would have store the current number index in a global variable. Something like: Code:
Sub Globals
'Declare the global variables here.
currentNumber = 0
Dim numbers(20)
End Sub
Sub App_Start
Form1.Show
For i = 0 To 19
number(i) = Rnd(1,101)
Next
'Show the numbers...
End Sub
Sub Button1_Click
If textbox1.text = number(currentNumber) Then
'correct answer
currentNumber = currentNumber + 1
Else
'wrong answer
End If
If currentNumber = 20 Then
'Finish
End If
End Sub
|
|
||||
|
Quote:
Your code should never loop unnecessarily as it eats up processor time that another app might be able to use, and on portable devices it wastes power and shortens battery life. |
|
||||
|
Hello,
Thank you for your firsts answers, but my problem is in fact a little bit more complicated than I first said. I don't know if I can do my program without a loop... In fact the number of numbers that the user must remember increase each time. Here is my actual code : Sub Bmemoirenouveau_Click score=0 For i=1 To 99 memoire(i)=Rnd(0,100) Next For i=1 To 99 For j=1 To i Msgbox("nombre à deviner n° " & j & ":" & memoire(j)) Next For j=1 To i Do Until bloque=0 Sleep(1000) Loop If TBmemoireessai.Text <> memoire(j) Then perdu End If Next score=score+1 Next End Sub Sub Bmemoireok_Click bloque=0 End Sub Sub perdu Msgbox("vous avez retenu " & score & " nombres") End Sub |
|
||||
|
Something like this?
Code:
Sub Globals
'Declare the global variables here.
score = 0
count = 1
currentNumber = 0
Dim numbers(100)
End Sub
Sub App_Start
Form1.Show
For i = 0 To 99
numbers(i) = Rnd(1,101)
Next
Shownumbers
End Sub
Sub Shownumbers
For i = 0 To count - 1
s = s &" " & numbers(i)
Next
Msgbox(s, "Your score is " & score)
End Sub
Sub textbox1_KeyPress(key)
If Asc(key) = 13 Then
If textbox1.text = numbers(currentNumber) Then
Msgbox("Correct!")
currentNumber = currentNumber + 1
score = score + 1
Else
'wrong answer
End If
textbox1.Text = ""
If currentNumber = count Then
count = count + 1
currentNumber = 0
Shownumbers
End If
End If
End Sub
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| event doubleclick and click on the cell (table object)... | micro | Questions & Help Needed | 2 | 08-19-2008 06:50 PM |
| Unwanted Click Event | Zenerdiode | Questions & Help Needed | 6 | 05-06-2008 06:25 AM |
| TreeView Click Event | RandomCoder | Basic4ppc Wishlist | 5 | 02-28-2008 04:23 PM |
| Do...Loop While | Put Claude | Questions & Help Needed | 1 | 07-24-2007 09:02 PM |
| Endless loop | Cableguy | Questions & Help Needed | 8 | 06-28-2007 05:36 PM |