VB sorting problem, VB in the specific procedure for sorting three numbers

Updated on educate 2024-02-08
5 answers
  1. Anonymous users2024-02-05

    Try my way:

    Create a text on the form, and a command1

    Then the click event in command1 is written as follows**:

    dim a() as string,i%,b() as integer

    a=split(text1," ") 'Enter the input numbers directly in text1, separated by spaces (one space) between the numbers.

    for i=lbound(a) to ubound(a)

    b(i)=val(a(i)) 'b is a numeric array.

    next i

    for i= lbound(b) to ubound(b)-1 'to loop the elements of the array.

    for j= i+1 to ubound(b)

    if b(j)t=b(j) 'then swap the positions of the two elements.

    b(j)=b(i)

    b(i)=t

    end if

    next j

    next i

    for i=lbound(b) to ubound(b) 'Outputs the order after the order is sorted on the form.

    print b(i)

    next i

  2. Anonymous users2024-02-04

    1. Start and create a new standard exe project.

    2. Draw a command button on the form, named command1.

    3. Double-click the command button to enter the ** window.

    4. Write a click event for a command button. Define a one-dimensional array a with 10 elements (1-10), randomly generate a batch of two-digit random numbers, load them into a(i) in an orderly manner, output a(i), and facilitate observation and comparison when the sorting is completed.

    5. Write the core part of the program.

    6. Broken line, output.

    7. Press F5 to run the test.

  3. Anonymous users2024-02-03

    First of all, the order of precedence of the three operators in the diagram is: mod, which is not in doubt;

    Then 8 1 = 8, 8 3 = divisor, there will be many decimal places in the system), the remainder is obtained by mod 2;

    In VB, the mod result is an integer, not a decimal, so it will be rounded, the result is 3, and the remainder is 1;

    The rounding principle is the banker's algorithm: the rounding rule, less than rounding, greater than carrying, odd or even not (is 0, is 2, is 2).

  4. Anonymous users2024-02-02

    Thinking of a method that may not be the best;

    Ideas: 1. Put the order you require and store it in an array;

    yd(1)="Wang",yd(2)="Chen",yd(3)="Lee",yd(4)="Zhao",yd(5)="Zhang",yd(6)="Liu"

    2. Create another array;

    nd(1)="",nd(2)="",nd(3)="",nd(4)="",nd(5)="",nd(6)=""

    3. Strings will appear randomly, for example: "Li, Chen, Zhao, Zhang".

    Split, and compare with the array yd one by one, and then assign the value to the array nd, and finally.

    Method 2: 1, the string in the original order: ys = "Wang Chen Li Zhao Zhang Liu".

    2. Your random occurrence string, for example: ss = "Li Chen Zhao Zhang".

    3. Do the loop:

    ns = ""

    for i = 1 to len(ys)

    if instr(ss, mid(ys,i,1)) 0 then

    ns = ns & mid(ys,i,1)end if

    next i

  5. Anonymous users2024-02-01

    You can do this with an array+for loop.

    First, you put Wang, Chen, Li, Zhao, Zhang, and Liu into the array dim arr() as string

    arr()=split("Wang, Chen, Li, Zhao, Zhang, Liu",","This random string is also a function written by yourself? Not quite understand the back sort easily.

    It is just to compare the random strings with this array, exchange them for the subscript values of the array, and sort the subscript values in order.

Related questions
10 answers2024-02-08

a = "n c hundred du q49232 ah ah ah pp"

mid(trim(a), 9, 5) 'From the 9th character from left to right (spaces are also counted), count 5 characters you want. >>>More

4 answers2024-02-08

Create a new project with two forms: form1, form2

There are two controls on form1: command button command1 and timer1There are two controls on form2: label label1 and timer1 click the command button when the program is running, the command button disappears, wait for 1 second and then pop up form 2 display: >>>More

15 answers2024-02-08

It's similar to a calculator.,Numbers can be entered on the interface.,You can also use the keyboard to enter.,Later dedicated**!! >>>More

6 answers2024-02-08

abs function: calculates the absolute value.

rnd function: Returns a single-precision number containing a random value. Without parameter, it is a decimal between 0 and 1. >>>More

29 answers2024-02-08

Many couples start by recognizing their sister!!

When I was in elementary school, I had a good brother who recognized the girl in my class as a sister, and guess what happened? >>>More