VB random number problem, how VB generates random numbers

Updated on technology 2024-05-04
3 answers
  1. Anonymous users2024-02-09

    option explicit

    private sub form_load()randomize

    dim pnumber as long

    dim picname(15)

    pnumber = int(rnd * 16) +1picname(1) = ""

    picname(2) = ""

    picname(15) = ""

    loadpicture( &picname(pnumber))end sub

    **Write your own name!!

    in its own directory.

  2. Anonymous users2024-02-08

    1. Open the "Microsoft Visual Basic Chinese" software and prepare a blank project file

    2. Then you need a command button, click the "Command Button" in the toolbox on the left, and drag the left mouse button on the right side of the form to draw

    3. Double-click the command button, here is the demonstration of entering ** print any integer between 0 and 10, and generate a random integer formula for other ranges as "int((upper limit - lower limit + 1) * rnd + lower limit)", if it is 1 to 53 is "int((1-53 + 1) * rnd+53":

    4. After writing, run the program, and every time you click the command button, you will print an integer between 0 and 10 on the form

  3. Anonymous users2024-02-07

    Random file is a file format similar to a database in VB, and the biggest difference between it and sequential files is that random files are stored in data blocks (sequential files are stored in rows or characters), just like dividing a large piece of cake into equal n pieces, and then you can take out one of the pieces at will, which is the origin of the name "random file". If you want to take out a certain line, because the number of words in each line is not necessarily equal, it cannot be taken out directly, and you must first take out each line in front of the line in order, until the line you need, so it is called "sequential file".

    It is precisely because random files can randomly extract any one of the data blocks, so some VB programs use random files as small databases.

    However, "random files" do not refer to a specific file type (or several)! It all depends on how the programmer opens the file. For example, if the same text file is opened randomly, it is a random file, if it is opened sequentially, it is a sequential file, and if it is opened in binary mode, it is a binary file.

    And not only text files, but any type of file (including exe executables) can be opened in random, sequential or binary mode with VB, the difference is that the effect of opening it may vary greatly.

    So don't bother looking for a specific so-called "random file", because it's not the file type, it's the way the file is opened! It's like when you hold a live chicken and say, "Why didn't I see Kung Pao Chicken?" ”

Related questions
6 answers2024-05-04

I don't understand how to use recursion in your program**, if you just don't let the string with 4 be generated, use a condition. >>>More

15 answers2024-05-04

rand() returns a random value ranging from 0 to rand max. Returns a random value between 0 and rand max, which is defined as , (with a value of at least 32767). >>>More

14 answers2024-05-04

dim x as long 'New.

get #1, ,r2 'Read the record of R2 from the first point in channel 1; get 1, 2, r2 read the 2nd record of r2 from inside channel 1. >>>More

16 answers2024-05-04

Here's a look: excel toolset 00130 generates random numbers (random time, random integers, random values, unique random values).

20 answers2024-05-04

Enter =round(rand()*a$1-2) in b1 and copy to the left.