Private Sub iCheckGs()
'--------verify password
Dim iPsw$, i&, tmp
iPsw = " " '"300029"
Do
tmp = InputBox( _
"Warm reminder from the system:" & Chr(10) & Chr(10) & _
""Non-professional users please click {Cancel} to exit!" & Chr(10) & Chr(10) & _
"Please enter your password (you still have " & 3 - i & " chances!)")
If Len(tmp) = 0 Then Exit Sub
If CStr(tmp) = iPsw Then Exit Do
If i >= 2 Then
Application.DisplayAlerts = False
ThisWorkbook.Close False
Application.DisplayAlerts = True
End If
i = i 1
Loop
'The following is the code after the password is passed
……
……
Sub Button 1_Click()
Dim Perimeter As Double, Area As Double, Radius As Double
Perimeter = 0
Area = 0
Radius = 15
#Call SubN(Perimeter, Area, Radius)
MsgBox Perimeter & " " & Area
End Sub
Sub SubN(ByRef perimeter parameter, ByRef area parameter, ByVal radius parameter)
If radius parameter
Perimeter parameter = 0
Area parameter = 0
Else
Perimeter parameter = 2 * 3.14 * Radius parameter
Area parameter = 3.14 * Radius parameter * Radius parameter
End If
End Sub The above code is debugged in Excel's VBA and can meet the requirements.
First of all, your ingN and ingSN are integer numbers. If the cell is a decimal, there may be a problem.
in addition
For Each rng2 In rng1.Cells
If rng2.Value """ Then
rng2.Select
ingTC = Val(ActiveCell.Offset(1, 0).Value ActiveCell.Offset(2, 0).Value)
End If
Next rng2
The result ingTC must be 0
Loop to the end rng2.Value is the bottom cell of the area
Val(ActiveCell.Offset(1, 0).Value ActiveCell.Offset(2, 0).Value)
The two lines below the area must be empty!
For Each rng3 In rng0.Cells
If rng3.Value = """ Then
shtV.Select
rng3.Select
ingN = Val(ActiveCell.Offset(-1, 0).Value)
End If
Next rng3
Depends on the situation of rng0.Cells
It’s all data, it doesn’t enter IF at all,
If there are more than 2 consecutive empty units, ingN must be 0.
According to the data you uploaded, the operation must be 0
I don’t understand what you want to do, so I don’t know how to change it.
in addition
If rng2.Value """ Then
rng2.Select
ingTC = Val(ActiveCell.Offset(1, 0).Value ActiveCell.Offset(2, 0).Value)
End If
is written as
If rng2.Value """ Then
ingTC = Val(rng2.Offset(1, 0).Value rng2.Offset(2, 0).Value)
End If
The efficiency will be much higher
The above is the detailed content of Get the value returned by InputBox in VBA. For more information, please follow other related articles on the PHP Chinese website!