.


:




:

































 

 

 

 


4.3.4-1. InputBox( ).




3

VB-,

 

 

4.3.1. VB-

4.3.2.

4.3.3. (ByVal)
(ByRef)

4.3.5. ()

4.3.6.

4.3.7. VB- .

 

,

 

4.3.7.2.

 

4.3.7.4.

(1- 2-)

 

VB-

 

Windows Forms , VB, , , , . , Windows Forms.

Windows Forms :

Option, , :

Option Explicit,

Option Compare,

Option Strict;

Imports, , ;

:

Public Class _

End Class;

:

Public Class _

End Class;

, Dim, Private

Public, , ;

, ;

, ,

, (

).

 


 

, VB

().

:

;

.

 

VB Windows Forms, , , , .

, ( , ) Dim, Private Public.

, , . 4.3.1-1.

 

 
Option Explicit On Option Strict On Option Strict On Imports System.Math Imports

 

Private Sub Form1

- 1 ( - 1)

- n ( n)
- 1

- m

 

End Class

 

. 4.3.1-1.

 

, , , , , . , . . , , , , , , .

 

, (). , , , . , , , , , . , (Private ) , . , Form2 Button1_Click(), Form1 .

, () , .

, , VB.

, ( Public Class Form1) Public Dim, _ . , , , .

, , , Total Integer:

Public Total As Integer Dim Total As Integer

, , , , .

4.3.2.

 

(.. ) (, Sqrt()), VB . , , . , ( ).

? , , - ().

, , . () () , . , . () . .

: - - . - - , - . , . , .

, , , .

 

, , - , . , .

, () ( ). , . , .

, ( ) , () . ByVal.

(). VB :

1) Function - -Function . - Function , , .

2) Sub - Sub . , . , - Function, - Sub , .

 

- Function - Sub () .

:

;

, .. () ;

, , , , ;

, , () , ; , , ;

( );

VB ( , VB).

 

- Function , Function End Function. - Function . , , - , . () , .

( ) -Function , , . - Function . , () , . () .

- :

 

Function () As Return = End Function

: ;

, , , ;

() , . . VB ByVal, , , ;

, ;

Return , , , . - , - .

 

- Sub - Function, , - Sub , .

Sub :

 

Sub () End Sub

 

:

- Sub.

() , , . . - Sub . VS ByVal, , - , . ByVal - Sub ByRef.

, .

 

- Sub , ( ), , () ( ), . , . , - Sub, , , ByRef. - Sub , .

 

 

4.3.3. (ByVal)
(ByRef)

 

, . , ( ). , , , ( ) ( ). , , ( ByVal ByRef ( ) ). , , . : (By Value) (By Reference). , .

, . ByVal ( ). , . , , . , , , , , .

, . ByRef , . , , , , .. . , , , , .

( ) .

, ByVal, - ByRef:

ByVa l , , ;

ByRef , ;

, ByVal, .

 

, (, ) .

, . , VB .

 

 

4.3.4.

 

, , .

 

    P1, P2, Pn , ,  

 

. 4.3.4-1.

 

/, /, (. .3-2). C . 4.3.4-1.

TextBox Text.

, , , Double - Function:

 

'-Function Double ' TextBox Function vvodDbl1(ByVal T As TextBox) As Double Return (Val(T.Text)) End Function

 

() , , x1 Double TextBox1 :

 

Dim x1 As Double x1 = vvodDbl1(TextBox1)

 

InputBox() VB , , .

InputBox() InputBox, (. 4.3.4-2):

, InputBox().
InputBox() , . , , . InputBox . 4.3.4-2.

 

 

 

.4.3.4-2.

 

InputBox() :

 

= InputBox (" ", " ")

 

,

, . , , ;

.

 

,

 

Name = InputBox(", , ", " ")

 

( . 4.3.4-3 ) MsgBox(). , , " ", , .

MsgBox() :

 

= MsgBox (" ", , " ")

 

,

, ;

, ;

.

 

. 4.3.4-1.

 

4.3.4-1

MsgBoxStyle.Ok
MsgBoxStyle.OkCancel
MsgBoxStyle.AbortRetryIgnore ,,
MsgBoxStyle.YesNoCancel , ,
MsgBoxStyle.YesNo ,
MsgBoxStyle.RetryCancel
MsgBoxStyle.Critical
MsgBoxStyle.Question ( )
MsgBoxStyle.Exclamation ( )
MsgBoxStyle.Information

 

.4.3.4-3.

 


4.3.4-1. InputBox().

1) c 4.3.4-1.

2) IDE 4.3.4-1.

3) , (Label) (Button). InputBox(). (. 4.3.4-4).

 

 

. 4.3.4-4. InputBox()

 

4) InputBox.

5)

Button1_li().

6) InputBox(), , . 4.3.4-5.

 

Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs)Handles Button1.Click Dim Prompt, FullName As String Prompt = " " FullName = InputBox(Prompt) MsgBox(FullName,, " ") Label1.Text = FullName End Sub

. 4.3.4-5.

4.3.4-1

Dim : Prompt FullName. String. ( , , , .)

Prompt . InputBox(). InputBox() ( , ) FullName. InputBox() VB, .

InputBox() , Text Label1 , , .

7) .

8) .

9) InputBox .

VB Button1_Click(),

InputBox.

10) , (. 4.3.4-6).

 

 

. 4.3.4-6. 4.3.4-1

 

InputBox() FullName. .

InputBox() , - . , .

11) ,
.

.

12) - Function vvodDbl2(), InputBox(),

:

 

 

'-Function Double Function vvodDbl2(ByVal p As String, ByVal T As TextBox) As Double T.Text = InputBox(P) Return CDbl(Val(T.Text)) End Function

 

, , x1 Double.

Dim x1 As Double x1 = vvodDbl2(" ", TextBox1)

 

, -, , , (, Text ), .

 

' Double TextBox Sub vivodDbl1(ByVal Z As Double, ByVal T As TextBox) T.Text = CStr(Z) End Sub

 

, , x1 Double :

Dim x1 As Double vivodDbl1(x1, TextBox1)

 

4.3.4-2. MsgBox() .

1) IDE, InputBox . 4.3.4-4.

2) Button1_Click() ( , ).

3) ( ):

4) Label1.Text = FullName.

5) FullName.

6) <Delete >, .

7) .

8) : MsgBox(FullName,, " ").

9) MsgBox(), FullName (. 4.3.4-7).

 

Public Class Form1 Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim Prompt, FullName As String Prompt = " " FullName = InputBox(Prompt) MsgBox(FullName,, " ") 'Label1.Text = FullName End Sub End Class

 

. 4.3.4-7. 3.4-2

 

1) .

2) InputBox , .

3) VB FullName, . ,
. 4.3.4-8.

 

. 4.3.4-8. 3.4-2

 

4) , . , .

5) - Sub vivodDbl2(), MsgBox() :

 

' Double MsgBox Sub vivodDbl2(ByVal Z As Double, _ ByVal S As String, ByVal T As TextBox) T.Text = MsgBox(CStr(Z), S) End Sub

 

, ,

x1 Double :

Dim z As Double vivodDbl2(z, " z", TextBox1)




:


: 2016-11-18; !; : 1292 |


:

:

, ,
==> ...

1530 - | 1514 -


© 2015-2024 lektsii.org - -

: 0.167 .