/    Sign up×
Community /Pin to ProfileBookmark

calling a vbScript Sub from a javaScript function

Can anyone please help me??
How can you call a vbscript Sub from a javascript?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliSep 29.2003 — should be pretty simple.just use the sub name in the JavaScript
Copy linkTweet thisAlerts:
@maria_papaauthorSep 30.2003 — nop......I did that. It doesn't work
Copy linkTweet thisAlerts:
@lilluSep 30.2003 — Well it's all about how vbscript (in ASP server-side I assume) and javascript (client-side) work together...

If you have IE this will work:

<script language="VBScript">

function VBsub(ByVal myMsg)

MsgBox(myMsg)

end function

</script>

Call the vbscript sub from somewhere in the page

<img onClick="VBsub('Hello!');" />

Without IE, I think you have to send the sub call to the server for processing then it will send back the result to your browser.
Copy linkTweet thisAlerts:
@James_L_Sep 30.2003 — I am not familiar with the term VB "sub", as I don't know Visual Basic, but I have embedded Visual Basic code (is that a sub?) directly into a javascript routine when I did a school assignment that involved browser and plug in detection.

Because IE Windows doesn't support the Navigator.plugins array, we could not use that method to detect if the Flash 6 plugin was present. The basic idea was to use Javascript to detect the browser, and if it was windows IE, then use the document.write method to write the visual basic script out. If it was any other browser that did support the navigator.plugins array then we just used Javascript for the detection.

Something like this (CODE SNIPPET):

if ((navigator.userAgent.indexOf("MSIE") != -1) && (navigator.appVersion.indexOf("Win") != -1))

// if the browser is a Windows based IE, use VBScript to determine which Flash version it is

{

document.write('<SCR' + 'IPT LANGUAGE=VBScript> n');

document.write('on error resume next n');

document.write('correctFlashVersion = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")))n');

document.write('</SCR' + 'IPT> n');

}

else....

the variable correctFlashVersion is a boolean previously defined within the Javascript. It worked fine having it defined by the embedded Visual Basic.

Not too sure if this is what you are looking for or not. Hope it helps.
Copy linkTweet thisAlerts:
@Khalid_AliOct 01.2003 — [i]Originally posted by maria_papa [/i]

[B]nop......I did that. It doesn't work [/B][/QUOTE]


In that case I can only say that you did not implemented the code correctly..

the code below will work in IE

the first part is in JavaScript and the second is in VBScript.if you click the button it will call javascript function which calls VBScript function that will print "hello from VBScript " string.

<script type="text/javascript">

<!--

function CallVBFunc(){

VBFunc();

//alert("Called");

}

//-->

</script>

<script type="text/VBScript">

<!--

sub VBFunc()

document.write "Hello From VBScript"

end sub

//-->

</script>

</head>

<body>

<input type="button" value="Call VB Function" onclick="CallVBFunc();"/>
×

Success!

Help @maria_papa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...