: b = x*Exp(Sqr(x))*cos(yx/x)
:
Private Sub Command1_Click()
Dim x As Integer, y As Single
x = Val(InputBox(" x", " "))
'x = Text1.Text
b = x*Exp(Sqr(x))*cos(y*x/x)
Text2.Text = b
Debug.Print y
MsgBox . vblnformation,
MsgBox "x=" & x & Chr(13) & "b=" & y,, " "
End
End Sub
, :
- Dim, Option Explicit -
- InputBox, MsgBox -
- Debug.Print -
- : Chr (), Val(), Str ().
- ( (Label), (TextBox), (CommandButton))
- (Name, Caption, Text)
- Show; Click
:
2
, .
2,3:
:
Private Sub Cmd1_Click()
Dim t As Double, w As Double
Const a As Double = 3, b As Double = 2
t = Val(TxtT.Text)
If t < 0, 1 Then
w = Sqr(a * t ^ 2 + b * Sin(t) + 1)
LblW.Caption = "w=Sqr(at ^ 2 + bsin(t) + 1)"
Else If t = 0, 1 Then
w = Sqr(a * t + b)
LblW.Caption = "w=Sqr(a * t + b)"
Else
w = Sqr(a * t ^ 2 + b * Cos(t) + 1)
LblW.Caption = "w=Sqr(a * t ^ 2 + b * Cos(t) + 1)"
End If
TxtW.Text = w
End Sub
Private Sub Cmd2_Click() ,
Private Sub Cmd2_Click()
TxtT.Text = ""
TxtW.Text = ""
LblW.Caption = ""
TxtT.SetFocus
End Sub
Private Sub Option2_Click() -
Private Sub Option2_Click()
If Option2.Value = True Then Image1.Visible = False
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then Image1.Visible = True
End Sub
, :
1)
If Then [Else ]
If 1 Then
1
[ElseIf 2 Then
2
... ]
[Else
n ]
End If
2) Select Case
Case 1
1
[Case 2
2
... ]
[Case Else
]
End Select
: (OptionButton); (Image).
: SetFocus.
-: ; .
|
|
( , ).
:
3
:
Private Sub Cmd1_Click()
Dim t As Double, w As Double
Const a As Double = 3, b As Double = 2
Dim min As Double, max As Double
Dim newline As String, space As String
newline = Chr(13) + Chr(10)
min = 1000: max = 0 \
Txt1.Text = " t " & " " & " w " & newline
t = Val(Txt2.Text)
Do While t <= Val(Txt3.Text)
If t < 0, 1 Then
w = Sqr(a * t ^ 2 + b * Sin(t) + 1)
Else If t = 0, 1 Then
w = Sqr(a * t + b)
Else
w = Sqr(a * t ^ 2 + b * Cos(t) + 1)
End If
\
If min > w Then min = w
If max < w Then max = w
If Chk1.Value = 1 Then
Txt1.Text = Txt1.Text & Format(t, "0.0") & " " & Format(w, "0.00") & newline
End If
t
t = t + Val(Txt4.Text)
Loop
\
If Chk2.Value = 1 Then
MsgBox "min =" & Format(min, "0.00") & newline & _
"max=" & Format(max, "0.00"), vbOKCancel + vbInformation, ""
End If
End Sub
-
Private Sub Cmd2_Click()
Txt1.Text = ""
Txt2.Text = ""
Lbl2.Caption = ""
Txt1.SetFocus
End Sub
-
Private Sub Cmd3_Click()
End
End Sub
, :
- (For...Next);
- (Do...Loop, While...Wend);
- ( Format),
- : (CheckBox); (Frame),
- MultiLine, ScrolBars, TablIndex ( , ).
1) For...Next :
For = To [Step ]
[Exit For]
[ ]
Next []
2) Do...Loop , :
Do [{While | Until} ]
[Exit Do]
[ ]
Loop[{While | Until} ]
:
4