create a file

I want to create a file to store random number. I have the code to gen

Page 1 of 1

0 Replies - 527 Views - Last Post: 15 December 2008 - 05:23 PM Rate Topic: -----

#1 camisarota  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-December 08

create a file

Post icon  Posted 15 December 2008 - 05:23 PM

‘I working in program in VB.net 2002 standard Version to generate 5 random numbers ‘from 1 to 35; I got those numbers right in 35 set of 5 , but to store them in a file and ‘can't do it. This is the program:
‘Manny
	' Dimension the variables used in the programme
		Dim intNumber As Integer
		Dim arrNumber(175) As Integer
		Dim i, x, y As Integer
		Dim m As Integer
		Dim a, b As Integer
		Dim cnt(35), tcnt(35) As Object
		Dim temp, s, ss As Integer
		Dim pass As Integer
		Dim n As Integer
		
	   'We want a total of 35 set of numbers, 5 numbers each set
			For m = 1 To 35
				'Do it 35 time



				For x = 1 To 5
Start:
					Randomize()

					intNumber = Int(35 * Rnd()) + 1 ' Random number 1 to 35
					For y = 1 To 5
						' Check arrNumber (y)
						'If intnumber has already been selected,
						'Then go and select another one.
						If intNumber = arrNumber(y) Then
							GoTo Start
						End If

					Next y
					'Place the next non-repeated number in the arrNumber(x).
					arrNumber(x) = intNumber
		  'to repeat a number five time in diferent set, no more than five 
					For b = 1 To 35
						If tcnt(B) = 175 Then GoTo Sort
						If arrNumber(x) = b And cnt(B) = 5 Then GoTo Start
						If arrNumber(x) = b Then cnt(B) = cnt(B) + 1
						tcnt(B) = tcnt(B) + 1


					Next b
				Next x

  Sort:

				For s = 1 To 5
					For ss = s + 1 To 5
						If arrNumber(s) > arrNumber(ss) Then
							temp = arrNumber(s)
							arrNumber(s) = arrNumber(ss)
							arrNumber(ss) = temp
						End If
					Next ss
				Next s

				
			  For i = 1 To 5

					Label1.Text = Label1.Text & (arrNumber(i)) & ";"

				Next i
				Label1.Text = Label1.Text & "   "

		Next m
  End Sub

   
	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		End
	End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Page 1 of 1