Click here to Skip to main content
15,914,350 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Help me with weird datagrid checkbox problem Pin
Kenshino5-Dec-06 5:29
Kenshino5-Dec-06 5:29 
AnswerRe: Help me with weird datagrid checkbox problem Pin
Kevin Nicol5-Dec-06 6:17
Kevin Nicol5-Dec-06 6:17 
GeneralRe: Help me with weird datagrid checkbox problem Pin
Kenshino5-Dec-06 10:08
Kenshino5-Dec-06 10:08 
GeneralRe: Help me with weird datagrid checkbox problem Pin
Kapil Thakur6-Dec-06 1:06
Kapil Thakur6-Dec-06 1:06 
AnswerRe: Help me with weird datagrid checkbox problem Pin
Kapil Thakur5-Dec-06 20:53
Kapil Thakur5-Dec-06 20:53 
GeneralRe: Help me with weird datagrid checkbox problem Pin
Kenshino5-Dec-06 23:57
Kenshino5-Dec-06 23:57 
GeneralRe: Help me with weird datagrid checkbox problem Pin
Kapil Thakur6-Dec-06 1:01
Kapil Thakur6-Dec-06 1:01 
QuestionHelp me tune up this class, pls Pin
king gamo5-Dec-06 3:05
king gamo5-Dec-06 3:05 
i have this class below which i'm using to uniquely generate a set of numbers. What it does is if i want 10 numbers randomly selected out of 11 i will pass it as a parameter to it and it'll return me the unique numbers. i dont want repetitions of the same number and it does what i want exactly... the problem is that atimes it gets into an infinite loop especially when i want 4 out of 5 or 3 out of 4.

the class


Public Class UniqueNumbers
Dim randCtr As New Random
Public Function genNumbers(ByVal totalNeeded As Integer, ByVal AvailableRange As Integer) As Integer()
Dim var1, var3 As Integer

Dim generatedNumbers(totalNeeded - 1) As Integer
Dim returnedNumbers(totalNeeded - 1) As Integer

For var1 = 0 To (totalNeeded - 1)
generatedNumbers(var1) = randCtr.Next(1, (AvailableRange + 1))
returnedNumbers(var1) = generatedNumbers(var1)
naa: For var3 = 0 To var1

If returnedNumbers(var3) = generatedNumbers(var1) Then
generatedNumbers(var1) = randCtr.Next(1, (AvailableRange + 1))
If var1 <> 0 Then
'varar(var1) = vararr(var1)
GoTo naa
End If
End If
Next
returnedNumbers(var1) = generatedNumbers(var1)


Next
genNumbers = returnedNumbers

Return genNumbers

End Function
End Class


all that i mean is if i want 3 out of 4
it can return 123 or 321 or 231 anything other than repeating one number twice like 112 or 122 or 332. My main problem is i want it to be faster and atimes it gets into a hang or infinite loop. Help me out guys.

Love makes the world go round
AnswerRe: Help me tune up this class, pls Pin
Guffa5-Dec-06 5:15
Guffa5-Dec-06 5:15 
Questionclick in datagrid's cell Pin
Smithers-Jones5-Dec-06 2:17
Smithers-Jones5-Dec-06 2:17 
AnswerRe: click in datagrid's cell Pin
Kevin Nicol5-Dec-06 3:01
Kevin Nicol5-Dec-06 3:01 
GeneralRe: click in datagrid's cell Pin
Smithers-Jones5-Dec-06 5:30
Smithers-Jones5-Dec-06 5:30 
QuestionNEED HELP NOW Pin
luna_harp5-Dec-06 2:10
luna_harp5-Dec-06 2:10 
AnswerRe: NEED HELP NOW [modified] Pin
ludoder5-Dec-06 2:59
ludoder5-Dec-06 2:59 
QuestionVisual Basic Script..(VBS) at Wincc Pin
TURKERWEB5-Dec-06 1:16
TURKERWEB5-Dec-06 1:16 
AnswerRe: Visual Basic Script..(VBS) at Wincc Pin
Dave Kreskowiak5-Dec-06 14:36
mveDave Kreskowiak5-Dec-06 14:36 
GeneralRe: Visual Basic Script..(VBS) at Wincc Pin
TURKERWEB5-Dec-06 21:04
TURKERWEB5-Dec-06 21:04 
QuestionI need help Pin
Derar Ziad5-Dec-06 0:49
Derar Ziad5-Dec-06 0:49 
AnswerRe: I need help Pin
Tamimi - Code5-Dec-06 1:03
Tamimi - Code5-Dec-06 1:03 
Questionhow to write code for datagrid sort command...... Pin
tirumal12315-Dec-06 0:47
tirumal12315-Dec-06 0:47 
QuestionFlash in .NET from Pin
IPhilVeryGood5-Dec-06 0:42
IPhilVeryGood5-Dec-06 0:42 
AnswerRe: Flash in .NET from Pin
milkyjoe5-Dec-06 6:11
milkyjoe5-Dec-06 6:11 
Questioni need one example keypress event Program in VB.Net Pin
somagunasekaran4-Dec-06 23:18
somagunasekaran4-Dec-06 23:18 
AnswerRe: i need one example keypress event Program in VB.Net Pin
king gamo5-Dec-06 3:27
king gamo5-Dec-06 3:27 
AnswerRe: i need one example keypress event Program in VB.Net Pin
Dave Kreskowiak5-Dec-06 14:33
mveDave Kreskowiak5-Dec-06 14:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.