1 / 4

Miscellaneous Topics

Miscellaneous Topics. Random Numbers. The Visual Basic function Rnd is used to return psuedo -random values (0 <= Rnd < 1 )

fredk
Download Presentation

Miscellaneous Topics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Miscellaneous Topics

  2. Random Numbers • The Visual Basic function Rnd is used to return psuedo-random values (0 <= Rnd < 1 ) • Use Randomize to initialize VB's random number generator. This is called seeding. To avoid generating the same sequence of psuedo-random values, call Randomize before you call Rnd • RandomizeVALUE=Int((HIGHESTNUM - LOWESTNUM) * Rnd + LOWESTNUM) • where VALUE is your variableHIGHESTNUMBER is the highest number for random generationLOWESTNUMBER is the lowest number for random generation • To Generate a Random number from 1 to 10: • RandomizeVALUE=Int((10 - 1) * Rnd + 1)

  3. Reading Text from a file Open App.Path + "employee.dat" For Input As #1 Input #1, emp_num For i = 1 To emp_num Input #1, Id(i), Name(i), Salary(i) Next Close

  4. Writing Text to a file Open App.Path + "employee.dat" For Output As #1 Write #1, emp_num For i = 1 To emp_num Write #1, Id(i), Name(i), Salary(i) Next Close

More Related