-
VB Simple Timing**:
**As follows: DIM S
private sub command1_click()= true
end sub
private sub command2_click()= false
end sub
private sub command3_click()= ""
s = 0end sub
private sub command4_click()endend sub
private sub form_load()= "Comprehensive application"
Timing (seconds):"
Total Time Elapsed (seconds):"
Get started" "Stop"
Re-time"Close"s = = 1000
falsetrueend sub
private sub timer1_timer()s = s + 1
s= send sub
private sub timer2_timer()= now
end sub
-
Let's make a calculator, it's pretty simple, I don't have time to write.
-
Your problem is mostly in the for loop.
In the first cycle, rent=160, you directly count the customer to 3, i.e. customer = customer - c
At this time, the number of customers is already 77, and it would be wrong to use this number of customers to calculate income (because when the rent is 160, it is 80 people, and the income is also calculated according to 80 people).
It should be calculated first, and then the customers can be counted to 3.
It's as simple as moving customer = customer - c to the line after the end if.
Also, your variable definition is a problem.
dim sum, room, rent, customer, p, c, maintain as integer
In this way, only maintain is an integer, and the others are variant types, and if you want to define them all as integers, you should write:
dim sum as integer, room as integer, rent as integer, customer as integer, p as integer, c as integer, maintain as integer
Also, p, c, and maitain are all fixed, and it is recommended to define them as constants (with const).
-
dim sum, room, rent, customer, p, c, maintain as integer
dim last_sum, last_rent, last_room as integer
private sub command1_click()
last_sum = 0for rent = 160 to 1000 step p
room = customer
sum = rent * room - maintain * room
if last_sum < sum then
last_sum = sum
last_rent = rent
last_room = room
end if
customer = customer - c 'Put this sentence here.
next rent
The maximum rent is:" & last_rent & "Yuan; The maximum number of rooms is as follows" & last_room & ";The maximum income is:" & last_sum & "Yuan; "
end sub
private sub form_load()
room = 80
customer = 80
rent = 160
maintain = 40
p = 20
c = 3end sub
VB design.
Introduction. What is required. >>>More
Two commandbuttons, two lables, two texts"
private sub command1_click()r = >>>More
The result of my run is: beq =
ub =optimization = >>>More
The second line declares that the textbox control array ** is wrong and does not conform to the syntax specification! >>>More
Good question, write with a for loop and judgment statement. >>>More