vb中Execute函数的用法?

在vbs中有个Execute 我觉的很好用,在vb中找到的的Execute 需要声明,声明后的意思好和vbs里的Execute 不一样。请教:怎么能让vb有vbs里Execute函数的功能?

vbs里execute是个函数,直接执行字符串。vb里execute是个方法,执行远程请求或者sql查询的。如果在vb里想实现vbs中execute同样的功能,有两种方法:①用api,不过编译之后出错,我不会解决,下面代码是度娘得到的。'Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
'
'Private Sub Command1_Click()
' Dim aa As String
' aa = "msgbox 2"
' Call ExecuteLine(aa)
'End Sub
'
'Private Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
' ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
'End Function②用scriptcontrol,完美解决!'Private Sub Command1_Click()
'Dim ob As Object
'Set ob = CreateObject("scriptcontrol")
'ob.Language = "VBscript"
'ob.AddObject "form1", Form1
'ob.ExecuteStatement "msgbox time"
'End Sub
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2018-03-12
vbs里execute是个函数,直接执行字符串。vb里execute是个方法,执行远程请求或者sql查询的。如果在vb里想实现vbs中execute同样的功能,有两种方法:①用api,不过编译之后出错,我不会解决,下面代码是度娘得到的。'Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
'
'Private Sub Command1_Click()
' Dim aa As String
' aa = "msgbox 2"
' Call ExecuteLine(aa)
'End Sub
'
'Private Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
' ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
'End Function②用scriptcontrol,完美解决!'Private Sub Command1_Click()
'Dim ob As Object
'Set ob = CreateObject("scriptcontrol")
'ob.Language = "VBscript"
'ob.AddObject "form1", Form1
'ob.ExecuteStatement "msgbox time"
'End Sub本回答被网友采纳
第2个回答  2015-09-10
vbs里execute是个函数,直接执行字符串。vb里execute是个方法,执行远程请求或者sql查询的。如果在vb里想实现vbs中execute同样的功能,有两种方法:①用api,不过编译之后出错,我不会解决,下面代码是度娘得到的。'Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
'
'Private Sub Command1_Click()
' Dim aa As String
' aa = "msgbox 2"
' Call ExecuteLine(aa)
'End Sub
'
'Private Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
' ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
'End Function
②用scriptcontrol,完美解决!
'Private Sub Command1_Click()
'Dim ob As Object
'Set ob = CreateObject("scriptcontrol")
'ob.Language = "VBscript"
'ob.AddObject "form1", Form1
'ob.ExecuteStatement "msgbox time"
'End Sub
第3个回答  2013-05-04
不可以

vb中Execute函数的用法?
vbs里execute是个函数,直接执行字符串。vb里execute是个方法,执行远程请求或者sql查询的。如果在vb里想实现vbs中execute同样的功能,有两种方法:①用api,不过编译之后出错,我不会解决,下面代码是度娘得到的。'Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long,...

VB 中Execute()如何使用?
execute是函数,直接执行。execute() 里面应该是sql语句。execute(1,1,1) 执行(1,1,1)

如何理解vb程序中的debug和execute
应用于 Find 对象的 Execute 方法。===运行指定的查找操作。如果查找成功,则返回 True。Boolean 类型。expression.Execute(FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics, MatchAlefHamza, Matc...

VB中,带命令参数的EXE程序怎样调用?
)用法:新建一个窗口,放入一个command按钮,复制下面代码到代码窗口中,其中:F:\\游戏\\Cs1.6中文版\\cstrike.exe为游戏路径。后边的那个为参数 Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As ...

inet控件的Execute的详细使用过程(VB)
Private Sub Command1_Click()Dim strURL As String, m_lDocSize As Long, strBuffer As String Dim lngArrivedDataSize As Long, strArrivedData As String strURL = "http:\/\/zhidao.baidu.com\/question\/68055519.html"Inet1.Execute strURL, "GET" '发出请求 Do While Inet1.StillExecuting '...

VB中的execute 添加新记录的前缀是什么
Dim cnStr As String, sqlStr As Strng cnStr ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\\\192.168.1.100\\Shared\\TestDB.mdb';"cn.Open cnStr sqlStr="insert into students(sid,name,sex,dob) values('001','Johnson','F'.#2001-02-25#);"cn.Execute sqlStr '执行SQL操作...

vb execute函数使用方法
要在"工程"菜单中引用对象库"Microsoft ActiveX Data Objects 2.8 Library",里面有好几个,2.5, 2.6,2.7都有,选取新的

VB中ShellExecute语法问题
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long 第1个参数hwnd是指父窗口的句柄,...

VB中数据库的Cnn.Execute怎么用?还有,其中的Cnn是什么东西?怎么...
Call Cnn.Execute("updata Jhssxd set Dx = '180' where Dx = '170'", iret) 中的updata不对,是update。

vb中的ShellExecute函数在c#中怎么用啊
1.using System.Runtime.InteropServices;2.[DllImport( "shell32.dll ")]public static extern int ShellExecute(IntPtr hwnd,StringBuilder lpszOp,StringBuilder lpszFile,StringBuilder lpszParams,StringBuilder lpszDir,int FsShowCmd);3.调用,打开记事本:int a...

相似回答