Something went wrong with the operation of this VB program

Updated on technology 2024-04-13
5 answers
  1. Anonymous users2024-02-07

    As far as the program is concerned, there are no errors.

    If you want to add from 1 to 100, swap the positions of s = s + i and i = i + 1.

    For the determination of the number of cycles, use for:

    private sub command1_click()dim s as long

    dim i as long

    for i=1 to 100

    s = s + i

    send sub

    Be sure to use the while (s=0 is redundant) word:

    private sub command1_click()dim s as long

    dim i as long

    do while i < 100

    i = i + 1

    s = s + i

    send sub

    private sub command1_click()dim s as long

    dim i as long

    i = 1do while i <= 100s = s + i

    i = i + 1

    send sub

  2. Anonymous users2024-02-06

    dim date1 should be put at the top, as a window variable or a global variable, in your case a process variable, if date2 > date1 + then

    date1 in is 0

    And date2 is also put on top, so it is not necessary to define it every time.

    dim date1 as date, date2 as dateprivate sub frmtimer_dragdrop(source as control, x as single, y as single)

    date1 = time 'now

    end sub

    private sub timer1_timer()= "times new roman"

    time()

    date2 = time

    if date2 > date1 + thenendend if

    end sub

  3. Anonymous users2024-02-05

    There is nothing wrong with the program running. What you mean is to perform from 1+......100?

    do while i <= 100

    s = s + i

    i = i + 1

    loop

  4. Anonymous users2024-02-04

    Put i=i+1 under s=s+i, otherwise you won't add 1, just from 2 to 101

  5. Anonymous users2024-02-03

    In Excel, VBA indicates that the subscript is out of bounds, indicating that the object does not exist or the array element does not exist.

    As a simple example: there is no one in the worksheet"January"This worksheet, however, uses sheets("January");The array defines arr(1 to 10), but arr(11) will be used, and the subscript will be out of bounds.

    To put it simply: an out-of-bounds subscript is a quote that is out of scope.

    1. When we enter the following ** in the VBA of Excel and run, there will be a prompt of "Error 9 subscript out of bounds during run". ** Below:

    sub a()

    dim arr() as string

    arr(1) = Hello"

    end sub

    2. In fact, the above "runtime error 9 subscript is out of bounds" is because the defined dynamic array does not determine the dimension and size. This problem can be solved by defining the fixed number of dimensions and dimensions, or by defining the dimensions and dimensions with redim.

    The corrected ** is as follows:

    sub a()

    dim arr() defines a dynamic array.

    dim i as integer

    redim arr(1 to 3) 'Define an array of 3 elements and initialize the array.

    arr(1) =3

    arr(2) =4

    arr(3) =5'In the following statement, redefine an array of 10 elements, clear the previous elements, and reassign new stored variables.

    redim arr(1 to 10)

    for i = 1 to 10

    arr(i) =i

    next i

    end sub, that's it.

Related questions
3 answers2024-04-13

Two commandbuttons, two lables, two texts"

private sub command1_click()r = >>>More

6 answers2024-04-13

The second line declares that the textbox control array ** is wrong and does not conform to the syntax specification! >>>More

6 answers2024-04-13

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

6 answers2024-04-13

I tried going downstairs with no problem. If it can't be opened, the landlord can try this sentence: (note that it is 3 quotation marks). >>>More

6 answers2024-04-13

Don't understand what you mean by startmark and enterstumark. >>>More