????? ??????? ?????? Script ????? ??????

?????? ????????? ?????? ?????????
???? ???????: 184740 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ????? ???????? ???????? ????? ?????? Script ???? ???????? ???????? ?? ??????? ????? ???????? ????? ?? Visual Basic.

??????? ????

???: ???? Microsoft ??????? ???????? ??? ??? ?? ???? ??????? ?? ?? ????? ? ? ?? ????? ??? ?????? ???????? ??????? ?/?? ???????? ???? ????. ????? ??? ??????? ??? ????? ??? ??? ??????? ???? ?? ????? ???????? ????????? ?????? ????????? ????????.

???? ??????? ???? ?????? Script VBScript ? JavaScript ?? ?????? ????????? ?? ??? ??????? ??????, ???? ???? ?????????? ?? ?????? ??? ??????? ????? ?? ?????? ?????? ???????? VBScript ?? JavaScript ?????? ????? ?????? ?????? ???.

?????? ??????? ??????? ?? "????? ??????? ?? Microsoft ????? ?????? ??? ???? ???? ???????? ?????:
184739: INFO: ???? ?????? ??? ?????? ?? ???????? ?????

???? ???? ?????? Script ?????? ??????? Sub ? ???? ?????? ????? ???????:
  • Eval: ????? ????? ??.
  • ???????: ????? ???? ???? ?? ????.
  • ?????: ??????? ????? ???????? ???.
  • ??????? ???? ?????? ???????.

eval

?????? ???????:
  Result = ScriptControl.Eval("some text expression")

				
???? ??????? ??? ??????? ??? ??????? ??? ????? ???????? ????? ???? ???????? ??? ????? ????????. ?????? ?????? ????? ?????? ????? ??????? ?? ???? ????? ? ???? ??? ??????? ????? ?????? ?? ?????? ?? ?????.

??????: ?? ???? ??????? ??? ??????? ??????? Subroutines.

?????

?????? ???????:
  Result = ScriptControl.Run("Name", arg1, arg2, ... argn)

				
???? ??????? ??? ??????? ??????? Subroutines ?? ?????? ????? ????? ???? ? ??????? ?????? ??????? ?????? ?????? ??????? ???????:
  ScriptControl.Run "Name", arg1, arg2, ... argn

				
??????: ??? ?? ????? ?? Sub ?? ???? ? arg1... argn ???????? ???????? ??? ???? ?? ???? ?? ??????.

?????

?????? ???????:
  ScriptControl.Execute "statement text"

				
??? ??????? ??????? ??????? ??? ???? ???? ?? Sub ?????. ????? ???????? ??????? ????? ???? ??? ????? ??????? ???????.

????? ?????? ???????

?????? ???????:
   Result = ScriptControl.Modules(modulename).functionname(arg1, arg2, ...)
   ScriptControl.Modules(modulename).subname arg1, arg2, ...
				

?????? ??????? ?????????? ???? GlobalModule ??? ???:
   Result = ScriptControl.Modules(GlobalModule).MyFunction(5)
   ScriptControl.Modules(GlobalModule).MySub 5, "A"
				

?????? ??? ???? ?? ????????? ??? ??????? ??????? ScriptControl ?????? ?????? ??????? ??????? ?? "????? ??????? ?? Microsoft:
184745: ????? ??????? ??????? ??????? ?????? Script ???????? ???????

??????

  1. ?? Visual Basic? ?? ?????? ????? ????. ??? ????? Form1 ???? ???????.
  2. ???? ??? "????????" ?? ??????? ??????? ?? ?? ?????? ???? ???????? "?????? Microsoft Script 1.0".
  3. ????? ???? ???? Script (ScriptControl1) ? ???? ?? (????1) ?? ??? (Command1) ??? ?????. ?? ?????? ????? ???? ???? ????? ?????? ??? True.
  4. ?? ?????? ????????? ???????? ??????? ??? Form1:
          Private Sub Command1_Click()
            With ScriptControl1
              ' Set script language (VBScript is the default).
              .Language = "VBScript"
              ' Set UI interaction (TRUE is the default).
              .AllowUI = True
              ' Copy the script to the control.
              .AddCode Text1.Text
              ' Demonstrate the Eval method.
              Debug.Print .Eval("AddTwo(5,7)")
              ' Demonstrate the Run method both with and without return values.
              .Run "Hello", "Jane Doe"
              Debug.Print .Run("Hello", "James Smith")
              .Run "AddTwo", 4, 6
              Debug.Print .Run("AddTwo", 7, 8)
              ' Demonstrate the ExecuteStatement method.
              .ExecuteStatement "Hello ""Sue Smith"""
              .ExecuteStatement "AddTwo 9,18"
              .ExecuteStatement "MsgBox CStr(AddTwo(3,8))"
              .Modules(GlobalModule).Hello "Jane Doe"
              Dim oMod As Object
              Set oMod = .Modules(GlobalModule)
              Debug.Print oMod.AddTwo 12, 24
              Set oMod = Nothing
            End With
          End Sub
    
    						
  5. ?? ?????? Form1 ?? ??? ???? ???????.
  6. ???? ???????? ????? ?????? ?? ???? ????:
          Sub Hello(YourName)
            MsgBox "Hello " & YourName
          End Sub
    
          Function AddTwo(X1, X2)
            AddTwo = X1 + X2
          End Function
    
    						
  7. ???? ??? CommandButton.

    ??????: ???????? ??????? ????? ?? ?????? ????? ??? ?????? ??????? ??? ????? ?? ???????? ???????? ????? ??????? ???? ?? ????? ???? ? ??? ???? ????? ?? ????? ?????:
          .Run "AddTwo", 4, 6
          .ExecuteStatement "AddTwo 9,18"
    
    						

?????

?????? ??? ??????? ??? ????? ?????? ??? ?????? Script ?????? ?????? ??????? ??????? ?? "????? ??????? ?? Microsoft:
184739: INFO: ???? ?????? ??? ?????? ?? ???????? ?????

(?) 1998 ???? Microsoft ? ???? ???? ?????.
????????? ?????? Malcolm Stewart ? ???? Microsoft

???????

???? ???????: 184740 - ????? ??? ??????: 27/????? ??????/1425 - ??????: 4.2
????? ???
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic 4.0 Standard Edition
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
  • Microsoft Visual Basic for Applications 5.0
????? ??????: 
kbmt kbhowto KB184740 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????184740

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com