Вывод решения вместо Immediate в textbox (visual basic 6.0) - VB
Формулировка задачи:
программа выводит решение в Immediate а я хочу разместить на форме text1 и что бы решение выводилось туда ,менял код менял не че не получается помогите.вот код проги она работает все норм только поменять нужно вместо вместо Immediate в textbox
Листинг программы
- Option Explicit
- Dim a As Double
- Dim b As Double
- Dim n As Double
- Function f(x As Double) As Double
- f = x * x - 2
- End Function
- Private Sub Command1_Click()
- Form1.Scale (-10, 10)-(10, -10) 'Scale Form1
- Dim x As Double
- Dim y As Double
- x = -10: y = f(x) 'Ustanovka nacala krivoy
- PSet (x, y)
- For x = -10 To 10 Step 0.1 'Izobrajenie krivoy
- y = f(x)
- Form1.Line -(x, y), vbBlue
- Next x
- Form1.Line (-10, 0)-(10, 0) 'gorizontalnaya os
- Form1.Line (0, -10)-(0, 10) 'vertikalnaya os
- Form1.DrawWidth = 3 'Tolshina krivoy
- For x = -10 To 10 Step 2 'Koordinatnaya setka
- PSet (x, 0): Print x
- Next x
- Form1.DrawWidth = 1
- End Sub
- Private Sub Command2_Click()
- Form1.Cls
- End Sub
- Sub PolDel(x As Double, y As Double)
- Dim z As Double
- z = (x + y) / 2
- If f(z) * f(y) <= 0 Then
- x = z
- Else
- y = z
- End If
- End Sub
- Private Sub Command3_Click()
- a = Val(InputBox("Vvod A", , 0))
- Form1.Line (a, 0)-(a, f(a)), vbRed
- Debug.Print "a ="; a
- b = Val(InputBox("Vvod B", , 0))
- Form1.Line (b, 0)-(b, f(b)), vbRed
- n = 0
- Debug.Print "b ="; b; "n ="; n
- End Sub
- Private Sub Command4_Click()
- n = n + 1
- PolDel a, b
- Form1.Line (a, 0)-(a, f(a)), vbRed
- Form1.Line (b, 0)-(b, f(b)), vbRed
- Form1.DrawWidth = 4
- Form1.PSet (a, 0)
- Form1.PSet (b, 0)
- Form1.DrawWidth = 1
- Debug.Print "a ="; a
- Debug.Print "b ="; b; "n ="; n
- End Sub
- Private Sub Command5_Click()
- Dim m As Byte
- m = InputBox("m=", , 0)
- Dim p1, p As Double
- Dim q1, q As Double
- a = -1: b = 3: n = 0
- Do
- n = n + 1
- PolDel a, b
- p = Round(a, m)
- q = Round(b, m)
- Loop Until p = q
- Debug.Print "p ="; p; "m ="; m; "n = "; n
- End Sub
- Private Sub Form_Load()
- Form1.Command1.Caption = "Krivaya"
- Form1.Command2.Caption = "Cls"
- Form1.Command3.Caption = "Vvod A B"
- Form1.Command4.Caption = "PolDel"
- Form1.Command5.Caption = "PoldelCycle"
- End Sub
Решение задачи: «Вывод решения вместо Immediate в textbox (visual basic 6.0)»
textual
Листинг программы
- Option Explicit
- Dim a As Double
- Dim b As Double
- Dim n As Double
- Function f(x As Double) As Double
- f = x * x - 2
- End Function
- Private Sub Command1_Click()
- Form1.Scale (-10, 10)-(10, -10) 'Scale Form1
- Dim x As Double
- Dim y As Double
- x = -10: y = f(x) 'Ustanovka nacala krivoy
- PSet (x, y)
- For x = -10 To 10 Step 0.1 'Izobrajenie krivoy
- y = f(x)
- Form1.Line -(x, y), vbBlue
- Next x
- Form1.Line (-10, 0)-(10, 0) 'gorizontalnaya os
- Form1.Line (0, -10)-(0, 10) 'vertikalnaya os
- Form1.DrawWidth = 3 'Tolshina krivoy
- For x = -10 To 10 Step 2 'Koordinatnaya setka
- PSet (x, 0): Print x
- Next x
- Form1.DrawWidth = 1
- End Sub
- Private Sub Command2_Click()
- Form1.Cls
- End Sub
- Sub PolDel(x As Double, y As Double)
- Dim z As Double
- z = (x + y) / 2
- If f(z) * f(y) <= 0 Then
- x = z
- Else
- y = z
- End If
- End Sub
- Private Sub Command3_Click()
- a = Val(InputBox("Vvod A", , 0))
- Form1.Line (a, 0)-(a, f(a)), vbRed
- Text1.SelText = "a =" & a & vbCrLf
- b = Val(InputBox("Vvod B", , 0))
- Form1.Line (b, 0)-(b, f(b)), vbRed
- n = 0
- Text1.SelText = "b =" & b & vbTab & "n =" & n & vbCrLf
- End Sub
- Private Sub Command4_Click()
- n = n + 1
- PolDel a, b
- Form1.Line (a, 0)-(a, f(a)), vbRed
- Form1.Line (b, 0)-(b, f(b)), vbRed
- Form1.DrawWidth = 4
- Form1.PSet (a, 0)
- Form1.PSet (b, 0)
- Form1.DrawWidth = 1
- Text1.SelText = "a =" & a & vbCrLf
- Text1.SelText = "b =" & b & vbTab & "n =" & n & vbCrLf
- End Sub
- Private Sub Command5_Click()
- Dim m As Byte
- m = InputBox("m=", , 0)
- Dim p1, p As Double
- Dim q1, q As Double
- a = -1: b = 3: n = 0
- Do
- n = n + 1
- PolDel a, b
- p = Round(a, m)
- q = Round(b, m)
- Loop Until p = q
- Text1.SelText = "p =" & p & vbTab & "m =" & m & vbTab & "n = " & n & vbCrLf
- End Sub
- Private Sub Form_Load()
- Form1.Command1.Caption = "Krivaya"
- Form1.Command2.Caption = "Cls"
- Form1.Command3.Caption = "Vvod A B"
- Form1.Command4.Caption = "PolDel"
- Form1.Command5.Caption = "PoldelCycle"
- End Sub
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д