|
-
Jul 4th, 2000, 06:25 AM
#1
Thread Starter
Junior Member
fairly simple really... i have a program that gives me six random numbers every time I click the button and it sores them in the database..
all I want to do is promt the user to enter the number of enries they wish to input into the database through an input box...so if they selected 10 it would loop through my code 10 times and add these to my database..any ideas??
cheers...
Rhys
-
Jul 4th, 2000, 06:44 AM
#2
PowerPoster
Code:
Dim Temp as String
Dim A as Long
Temp = InputBox( "Enter number:" )
If IsNumeric( Temp ) Then
For A = 1 to Temp
AddItem InputBox( "Enter Item number " & A & ":" )
Next
Endif
Is that what you are looking for?
-
Jul 4th, 2000, 06:45 AM
#3
_______
/?\
Private Sub Command1_Click()
Dim sNumbers As Integer
Dim newNum As Integer
Dim i As Integer
sNumbers = InputBox("Enter your numbers")
Randomize
Dim iArr()
For i = 1 To sNumbers
ReDim iArr(sNumbers)
newNum = Int(Rnd * sNumbers)
iArr(i) = newNum
List1.AddItem 'this is just for display
'remove it and save your stuff to your database here
' ie. data1.recordset!storenumberfield = iarr(i)
Next i
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 4th, 2000, 09:42 AM
#4
Thread Starter
Junior Member
All I want it do is repaet the code behind the button..so if they press 10 times it does it 10 times instead of having to press the button 10 times....can you see what im saying..cos im starting to confuse myself!!!!!!!!!
Rhys :0)
-
Jul 4th, 2000, 10:46 AM
#5
Try this. Make a Form with a FlexGrid and place the following code into a CommandButton.
Code:
Private Sub Command1_Click()
Dim RetVal As Integer
Dim MyNum As Integer
'Get how many entries (How many times to loop the code)
RetVal = InputBox("How many entries?")
'Loop it was many times as specified in RetVal
For X = 1 To RetVal
For I = 1 To 6
'Generate Random Numbers
Randomize
MyNum = Int(Rnd * 100) + 1
'Adds to the next column in the FlexGrid
MSFlexGrid1.AddItem Chr(9) & MyNum
Next I
Next X
End Sub
-
Jul 4th, 2000, 11:11 AM
#6
Thread Starter
Junior Member
my code is below:
as you will see it adds the numbers to each different label although the above suggestion is what I want how can I get it to do this on my code so that each label can be added to the database.
???????????????
Dim x As Integer
Dim y As Integer
Dim Numbers(1 To 50) As Boolean
Dim Labels(1 To 6) As Integer
Dim TempInt As Integer
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Data1.Recordset.AddNew
For x = 1 To 50
Numbers(x) = False
Next x
x = 0
Do
x = x + 1
Randomize
TempInt = Int((Rnd * 49) + 1)
For y = 1 To 50
If TempInt = y Then
If Not Numbers(y) Then
Numbers(y) = True
Labels(x) = TempInt
Exit For
Else
x = x - 1
Exit For
End If
End If
Next y
Loop Until x = 6
Text1.Text = Labels(1)
Text2.Text = Labels(2)
Text3.Text = Labels(3)
Text4.Text = Labels(4)
Text5.Text = Labels(5)
Text6.Text = Labels(6)
End Sub
-
Jul 4th, 2000, 11:56 AM
#7
Try placing this at the end of your code. It will loop through through Labels and add it to the FlexGrid.
Code:
For I = 1 To 6
'Loop through the labels and add them
MSFlexGrid1.AddItem Chr(9) & (Labels(I))
Next I
-
Jul 4th, 2000, 12:38 PM
#8
_______
/???\
in your form active or whereever
open your database and set your datacontrol/recordset
'adjust your code betweent he lines next y and loop until
Next y
yourdatacontrol.yourrecordset.addnew
yourdatacontrol.yourrecordset!yourfield = labels(x)
yourdatacontrol.yourrecordset.update
Loop Until x = 6
close your database on exit from app
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|