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

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

?? ????? ??

??????

?? ???? ??????? ??????? ??? ?? Visual Basic ????????? ?????? ?? ??? ?? ????????? ???? ?? ?? ??? ???????? ?? ??? ????? ??? ?????? ???? ???

???? ???????

??????????: Microsoft ???????????? ?????? ?? ?????? ????? ??, ???? illustration ?????? ?? ?? expressed ?? ???????, ????? ???? ?? ???, ??????? ?????? ?? ?????? ??/?? ???? ????? ???????? ?? ??? ????????? ????? ???? ????? ????? ?? ???? ????? ?? ?? ?? demonstrated ?? ??? ???????????? ???? ?? ????? ?? ???????????? ?? ???? ???? ?? ??? ????? ??? ??????? ?? ?????? ????

????????? ???????? ?? ???? ??? ????? VBScript, JavaScript ?? ???? ?? ???? ?????? ???????????? ????, ???? ???? ?????????? VBScript ?? JavaScript ??? ????? ?? ??? ???????? ??????????? ?????? ????? ?? ??? ????? ???? ?? ??? ?? ???? ??? ?? ???? ????????? ????????? ?? ???? ????

????? ???? ?? Microsoft ???????? ??? ????? ?? ????? ???? ?? ??? ???????? ??????? ???? ?? ??? ???? ????:
184739: ?????: ???? ????????? ???????? ??????? ???? ?? ???

????????? ???????? ?? ?? ?????? ?? ??? ???? ?? ??? ??? ??????? ????????? routines ?????? ???? ??:
  • Eval: ??? ??? ?????????? ????????? ???? ???
  • ?????: ??? ??? ?? ?? ?????? ????? ???
  • ?????????: ??? ????????? ??? ????????? ???? ???
  • ??????? ???????? ?? ???? ?? ??? ????

Eval

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

				
????? intrinsic ????????? ?????? ?? ??? ???? ?? ??? ?? ?? ???? ?? ????? ?? ???? ??? ?????????? ?????? ?? ??? ??? ?????? ???? ?????????? ??? ??? ??????? ??? ?? ??? ??? ??? ??? ??? ?? ?? ???? ??? ?? ?? ?????-coded ?? ?? ?? concatenated.

????? ???: ?? ?????? Subroutines ??? ???? ?? ??? ????? ???? ???? ?? ?????

?????

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

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

				
????? ???: ??? ?? ??? ?? ?? ?? ??????, ??... arg1 argn ??? ?? ?? ?????? ??? question ?? ???? ?? ???????? ???

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

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

				
?? ???? ????? Sub ???? ?? ???? ?? intrinsic ??? ?? ??? ???? ?? ?????? ???? ??? ?? ?? ????? ?? ???? ?? ?????? ?? ??? ???? ?? ???, ????? ????? ?????? ????? ?? ?? ???

??????? ????

?????? ????? ??:
   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: ???? ????? ????????? ???????? ??????? ?? ???????????? ??????

??????:

  1. Visual Basic ??? ??? ??? ????????? ?????? Form1 ???????? ??? ?? ???? ??..
  2. ??? ?? ' ????????? ' ???? ?? ????? ????, ?? ???? ??? "Microsoft ????????? ???????? 1.0" ??? ????? ?? ??? ?????
  3. ???? ??????? ?? ??? ????????? ???????? (ScriptControl1), ???? ??? ????? (Text1) ?? (Command1) ???? ??? ??????? ??? ????? ?? MultiLine ??? ?? ??? ???? ?? ??? ??? ?????
  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"
    
    						

??????

????????? ???????? ??????? ???? ?? ???? ??? ??????? ?? ??? ????? ????? ???? ?? Microsoft ???????? ??? ?????:
184739: ?????: ???? ????????? ???????? ??????? ???? ?? ???

(?) Microsoft Corporation 1998, ??? ?????? ?????????
???????? ?? Malcolm ?????????, Microsoft Corporation ?? ??????

???

???? ID: 184740 - ????? ???????: 02 ?????? 2010 - ??????: 3.0
???? ???? ???? ??:
  • Microsoft Visual Basic 5.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 4.0 Standard Edition
??????: 
kbhowto kbmt KB184740 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??: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