■■怎样调用JAVASCRIPT的函数?■■

laisiwei 2002-06-10 08:46:33
Javascript有一个escape函数,在VB中怎样才能调用它,或者谁有它的VB源代码。我都将以高分相送。
...全文
60 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
laisiwei 2002-06-10
  • 打赏
  • 举报
回复
Dim Adsffsd As String
Adsffsd = "45345634534565 fd"

Text2.Text = ScriptControl1.Eval("escape(Adsffsd)")

显示“Adsffsd 未定义”
错在哪了?
IsMe 2002-06-10
  • 打赏
  • 举报
回复

Dim moScript As MSScriptControl.ScriptControl
Set moScript = New MSScriptControl.ScriptControl
moscript.language="JavaScript" 'or "VBScript"
msgbox moScript.Eval("escape('a')")
IsMe 2002-06-10
  • 打赏
  • 举报
回复

Dim moScript As MSScriptControl.ScriptControl
Set moScript = New MSScriptControl.ScriptControl
moscript.language="JavaScript" 'or "VBScript"
msgbox moScript.Eval("escape('a')")
laisiwei 2002-06-10
  • 打赏
  • 举报
回复
怎么用?
孙小雄 2002-06-10
  • 打赏
  • 举报
回复
ScriptControl Object


引用 Microsoft Script Control 1.0

laisiwei 2002-06-10
  • 打赏
  • 举报
回复
这个控件在VB里叫什么,或者哪边可以下载?
IsMe 2002-06-10
  • 打赏
  • 举报
回复
使用msscript控件可以调用vbs和js的过程,计算其表达式
kittyGirl 2002-06-10
  • 打赏
  • 举报
回复
'這個程式需要2個Command,3個TextBox


Option Explicit
Private Const MAX_PATH As Long = 260
Private Const ERROR_SUCCESS As Long = 0

Private Const URL_DONT_ESCAPE_EXTRA_INFO As Long = &H2000000
'Don't convert the # or ? character, or any characters following them in the string.
Private Const URL_ESCAPE_SPACES_ONLY As Long = &H4000000
'Only escape space characters. This flag cannot be combined with URL_ESCAPE_PERCENT or URL_ESCAPE_SEGMENT_ONLY
Private Const URL_ESCAPE_SEGMENT_ONLY As Long = &H2000
'Escape the sections following the server component, but not the extra information sections following a # or ? character.
Private Const URL_ESCAPE_PERCENT As Long = &H1000
'Escape the % character. By default, this character is not escaped

Private Const URL_UNESCAPE_INPLACE As Long = &H100000
'Use pszURL to return the converted string instead of pszUnescaped.
Private Const URL_INTERNAL_PATH As Long = &H800000

Private Declare Function UrlEscape Lib "shlwapi" Alias "UrlEscapeA" (ByVal pszURL As String, ByVal pszEscaped As String, pcchEscaped As Long, ByVal dwFlags As Long) As Long
Private Declare Function UrlUnescape Lib "shlwapi" Alias "UrlUnescapeA" (ByVal pszURL As String, ByVal pszUnescaped As String, pcchUnescaped As Long, ByVal dwFlags As Long) As Long


Private Sub Form_Load()
Text1.Text = "http://vbnote.cjb.net/s o m t t e x t h e r e.html"
Text2.Text = ""
Text3.Text = ""
Command1.Caption = "去除空白"
Command2.Caption = "回復空白"
End Sub


Private Sub Command1_Click()
Dim SUrl As String, dwSize As Long
Dim sUrlEsc As String

SUrl = Text1.Text
sUrlEsc = Space(MAX_PATH)
dwSize = Len(sUrlEsc)

UrlEscape SUrl, sUrlEsc, dwSize, URL_ESCAPE_SPACES_ONLY

sUrlEsc = Left(sUrlEsc, dwSize)

Text2.Text = sUrlEsc
End Sub

Private Sub Command2_Click()
Dim sUrlEsc As String, dwSize As Long
Dim sUrlUnEsc As String
sUrlEsc = Text2.Text
sUrlUnEsc = Space(MAX_PATH)
dwSize = Len(sUrlUnEsc)
UrlUnescape sUrlEsc, sUrlUnEsc, dwSize, URL_INTERNAL_PATH
sUrlUnEsc = Left(sUrlUnEsc, dwSize)
Text3.Text = sUrlUnEsc
End Sub

luckysusan 2002-06-10
  • 打赏
  • 举报
回复
因為你定義的變量Adsffsd不是在javascript中定義的
修正如下:

Dim Adsffsd As String
Adsffsd = "45345634534565 fd"

ScriptControl1.AddCode ("Adsffsd = '45345634534565 fd'")
Text2.Text = ScriptControl1.Eval("escape(Adsffsd)")
試一試!應該沒有問題.

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧