Click here to Skip to main content
16,011,949 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Sorting and keeping an index [modified] Pin
CPallini29-Dec-06 23:51
mveCPallini29-Dec-06 23:51 
Questionconnection string Pin
jds120729-Dec-06 10:26
jds120729-Dec-06 10:26 
AnswerRe: connection string Pin
Dave Kreskowiak29-Dec-06 10:37
mveDave Kreskowiak29-Dec-06 10:37 
AnswerRe: connection string Pin
Paul Conrad29-Dec-06 10:38
professionalPaul Conrad29-Dec-06 10:38 
QuestionName Backwards Pin
shotgun2129-Dec-06 10:13
shotgun2129-Dec-06 10:13 
AnswerRe: Name Backwards Pin
KevinMac29-Dec-06 13:45
KevinMac29-Dec-06 13:45 
QuestionGenerating random numbers Pin
UncleMikey29-Dec-06 8:15
UncleMikey29-Dec-06 8:15 
AnswerRe: Generating random numbers Pin
CPallini29-Dec-06 8:36
mveCPallini29-Dec-06 8:36 
The trick is simulating what happens in real world.
Suppose you have to extract five (distinct) numbers from fifty ones.
You first initialize an array
For n=1 to 50
  num(n)=n
next n


then you extract the five numbers into the extracted array

for k=0 to 4
  r = CInt(50 * Rnd() + 1 - k))
  extracted(k) = num(r)
  swap(num(r), 50 - k )
next k


As you can see, each time the extracted value is swapped with the element at the and of the array and the following choice is done on a narrowed array.

Hope that helps (I wrote the code remembering the algo, i.e. I did not verify it, only to illustrate the algo itself).



If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

QuestionRe: Generating random numbers Pin
UncleMikey29-Dec-06 9:57
UncleMikey29-Dec-06 9:57 
AnswerRe: Generating random numbers Pin
CPallini29-Dec-06 10:13
mveCPallini29-Dec-06 10:13 
QuestionProgram wont run; already Published and installed Pin
Karma3125129-Dec-06 4:30
Karma3125129-Dec-06 4:30 
AnswerRe: Program wont run; already Published and installed Pin
Dave Kreskowiak29-Dec-06 9:26
mveDave Kreskowiak29-Dec-06 9:26 
GeneralRe: Program wont run; already Published and installed Pin
Karma3125129-Dec-06 9:29
Karma3125129-Dec-06 9:29 
GeneralRe: Program wont run; already Published and installed Pin
Dave Kreskowiak29-Dec-06 9:36
mveDave Kreskowiak29-Dec-06 9:36 
GeneralRe: Program wont run; already Published and installed Pin
Karma3125129-Dec-06 9:39
Karma3125129-Dec-06 9:39 
GeneralRe: Program wont run; already Published and installed Pin
Dave Kreskowiak29-Dec-06 15:04
mveDave Kreskowiak29-Dec-06 15:04 
QuestionCan I run vb or com components Pin
indian14329-Dec-06 1:58
indian14329-Dec-06 1:58 
AnswerRe: Can I run vb or com components Pin
Dave Kreskowiak29-Dec-06 3:25
mveDave Kreskowiak29-Dec-06 3:25 
QuestionDataGridView doesnot update in vb.net 2005 Express Edition Pin
Dharmit29-Dec-06 1:31
Dharmit29-Dec-06 1:31 
NewsHiEdit V1.0.1.4 Pin
akyprian28-Dec-06 21:36
akyprian28-Dec-06 21:36 
GeneralRe: HiEdit V1.0.1.4 Pin
Dave Kreskowiak29-Dec-06 3:24
mveDave Kreskowiak29-Dec-06 3:24 
GeneralRe: HiEdit V1.0.1.4 Pin
akyprian29-Dec-06 4:13
akyprian29-Dec-06 4:13 
GeneralRe: HiEdit V1.0.1.4 Pin
CPallini29-Dec-06 6:08
mveCPallini29-Dec-06 6:08 
GeneralRe: HiEdit V1.0.1.4 Pin
akyprian29-Dec-06 6:50
akyprian29-Dec-06 6:50 
QuestionHow can I take the backup of SQL server database through coding Pin
indian14328-Dec-06 20:45
indian14328-Dec-06 20:45 

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.