Help solve a problem with the VB program, a problem in VB

Updated on educate 2024-02-09
6 answers
  1. Anonymous users2024-02-05

    Good question, write with a for loop and judgment statement.

    private sub command1_click()dim tuzi as integer

    dim ji as integer

    for tuzi = 1 to 40

    for ji = 1 to 80

    if tuzi * 4 + ji * 2 = 160 and tuzi + ji = 50 then

    If the total number of legs of the rabbit and chicken is 160, and the rabbit and chicken are 50, the result msgbox ("The number of rabbits and chickens is as follows:" & tuzi & "、" & ji)

    end if

    next next

    end sub

    Hehe, I think of for and if when I want to solve any problem recently, I can't be saved! Also, rabbits are four-legged, right?

  2. Anonymous users2024-02-04

    1) Let the chicken x and the rabbit y, then the system of equations can be listed according to the meaning of the question:

    x+y=50

    2x+4y=160, the solution is x=30, y=202)dim m as integer, n as integerm=50n=160

    print "Chickens are shared";2*m-n/2;"Only,";

    print "There are rabbits in total";n/2-m;"Only,"

  3. Anonymous users2024-02-03

    Comrade upstairs! Your system of binary equations is reversed, and the system of equations is correct but x 20, y 30 hee-hee.

  4. Anonymous users2024-02-02

    Bright statement dim ah (3,-2 same as 2,5).

    Equivalent to dim (0...)3 ,-2..2,0..5) Equivalent to x has 4 rows (0 1 2 3).

    y has 5 rows (-2 -1 0 1 2).

    z has 6 rows (0 1 2 3 4 5 6).

    So the length of the entire array is 4*5*6=120

  5. Anonymous users2024-02-01

    The first dimension is 0 to3, the second dimension is -2 to 2, and the third dimension is 0 to 5, so 4*5*6=120

  6. Anonymous users2024-01-31

    The points of study in this question:

    1.Calculation of the total number of elements in a multidimensional array (equal to the product of the number of elements in each dimension)2The number of elements is known to be the upper and lower limits (the difference between the upper and lower limits + 1)3

    The default upper limit value when the upper limit is not specified (is 0.)This can be adjusted using an option base statement (e.g., option base 1), but it is 0 by default).

    Sum up. 1.The upper and lower limits of the 3-dimensional completion array: 0 3, -2 2, 0 52Calculate the number of elements per dimension: 3-0+1=4, 2-(-2)+1=5, 5-0+1=6

    3.Multiply all: 4*5*6=120

    120 is what is sought.

Related questions