Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript eqivalent to TRY..CATCH 1

Status
Not open for further replies.

safaritek

Programmer
Feb 13, 2003
79
CA
I am looking for an equivalent to JavaScript's "TRY ... CATCH" functionality.

My project is a web based VBScript application and I need it to perform a datasave as part of a separate set of VB functions during a button press.

The only snippet I could find to do the data save was a JavaScript snippet that uses TRY..CATCH - according to my VBScript help, there is no TRY command available. (and of course I cannot call a JavaScript function from within VBScript, otherwise there would not be any issue)

The JavaScript I need to convert to VBScript is as follows:

Code:
<SCRIPT language=javascript>
Function SaveData(){
  try { if (MSODSC.DataPages.Count > 0)
      if (MSODSC.CurrentSection == null)
	   MSODSC.DataPages(0).Save();
      else
	   MSODSC.CurrentSection.DataPage.Save(); }
  catch (e)
  { alert (e.description);}
}
</SCRIPT>


Any and all help is appreciated.
 
safarietk,

It is something like this.
[tt]
try {
//do a,b,c
} catch(e) {
//do x,y,z instead
}
[/tt]
can be rendered as this
[tt]
on error resume next
'do a,b,c
if err.number<>0 then
'do x,y,z instead
err.clear
end if
on error goto 0
[/tt]
Of course, the tighter the task (a,b,c) the better the focus of the control.

regards - tsuji
 
I cannot call a JavaScript function from within VBScript
Really ?
 
Depends on where you're using VBScript. In an ASP web page, it often won't work because of the way the scripting engines are used to process things. In a WSH page, I thought I remembered reading in the documentation that you can use and mix any number of scripting languages that are WSH compatible.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top