VB程序中使用脚本支持
正在开发小秘书系统并不断提高其智能水平,其中用到的是脚本支持的技术
虽然这部分不属于初学者使用,然而有些人想学这个东东,这里就发~~~布出去吧!
新建一个标准exe工程(Standard EXE);
"工程"(Project)-->"部件"(Components)
选定"Microsoft Script Control 1.0" ,位置是C:\WINDOWS\system32\msscript.ocx
添加控件到工程,个人爱好我命名mscScript
然后添加一些控件,得到如下图的界面,然后是下面这些函数,过程:
Private Sub Form_Load()
mscScript.AddObject "frmMain", frmMain
mscScript.AddObject "objScript", objScript
End Sub
'---------------------------------------
'vbClass Moudle clsFunction
'---------------------------------------
Public Function strRun(ByVal str As String) As String
Dim strName As String
Dim strExpress() As String
strName = Left(str, InStr(str, " ") - 1)
strExpress = Split(Mid(str, InStr(str, " ") + 1), ",")
strRun = CStr(frmMain.mscScript.Run(strName, strExpress(0), strExpress(1)))
End Function
需要注意是类模块要生成对象:Public objScript As New clsFunction,这个知识在一般程序开发下很少接触;
然后就是vbScript(脚本)和Visual Basic的区别,前者是后者的子集,语法上不能混乱
最常见的错误是:vbscript的变量只有Variant类型,Next 后面不跟变量名等...
源代码在我的资源那里有,
http://prsniper.download.csdn.net/user/prsniper/all/1
希望更多的人学好编程,不断提高技术,深度的探讨可以加我QQ:627666017
空间只面向新手,,,
相关文档:
Dim ReturnValue, I
ReturnValue = Shell("Calc.EXE", 1) ' 运行计算器。
AppActivate ReturnValue ' 激活计算器。
For I = 1 To 100 ' 设置计数循环。
SendKeys I & "{+}", True ' 按下按键给计算器
Next I ' 将所有 I 值相加。
SendKeys "=", True ' 取得总合。
SendKeys "%{F4}", True ' 按 ALT+F4 关 ......
把鼠标移到屏幕指定位置 如(111.111) 单击一下
再移到屏幕另一指定位置指定位置 如(222.222)单击一下
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Function SetCursorPo ......
Option Explicit
' VB / VBA Functions for Code128(A, B,C), UCC/EAN 128
' Copyright 2004 by MW6 Technologies Inc. All rights reserved.
'
' This code may not be modified or distributed unless you purchase
' the license from MW6.
Public UFPrefixFunctions As Boolean
Private I As Integer
Pri ......
Option Explicit
Public Function ascii2Char(strInput As String) As String
Dim i As Integer
Dim strTemp As String
Dim nPos As Integer
Dim nValue As Integer
i = 1
nPos = InStr(i, strInput, "&#", vbTextCompare)
While (nPos > 0)
ascii2Char = ascii2Char + Left(st ......
http://topic.csdn.net/t/20030306/11/1497896.html#
工程文件名:Chdsp.vbp
Type=Exe
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\PWIN95\SYSTEM\\STDOLE2.TLB#OLE Automation
Module=Module1; ChDsp.bas
Form=ChDsp.frm
Startup="Form1"
He ......