This is a multi-part message in MIME format.
--------------090702000508020807070209
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

In a previous posting, a scripter using scripting language other
than vbScript, and further a language which has no math functions,
and was wondering if there was some com object that would offer
the capability of calling the vbs math functions.

A previous response to that O.P. recommended installing the ms
"Script Control", and place some vbScript coding inside the control
to calculate the desired math functions.

In addition to that, if you are courageous enough, or foolhardy enough,
to call api's from script, then you can call the (vb) math functions
directly. All you need is a relatively "light-weight" com control
suitable for calling api's, which you could write yourself, or use
one already available, like: "DynaWrap".

Note that there are several (standard) dll's around containing math
function entry points. Among these are the "vb runtimes": msvbvm50.dll,
and msvbvm60.dll, plus vba5.dll and vba6.dll, any of which you may
have if you have any vb5 or vb6 apps installed on your system. You
can also find the math functions in vbar332.dll, which you will have
if you have VBA (Visual Basic for Applications) on your system.

Here are the vb-style declarations for the math functions entry-
points:

Declare Function rtcCos Lib "msvbvm60.dll" (ByVal dblNumber As Double)
As Double
Declare Function rtcSin Lib "msvbvm60.dll" (ByVal dblNumber As Double)
As Double
Declare Function rtcSqr Lib "msvbvm60.dll" (ByVal dblNumber As Double)
As Double
Declare Function rtcTan Lib "msvbvm60.dll" (ByVal dblNumber As Double)
As Double

by now, you get the drift. I don't have an exact exhaustive
listing, but you should be able to find at least: Sine, Cosine,
Tangent, ArcTangent, Exp, Log, and Sqrt. Many (if not most) of
the other functions may be derived from those just listed.

There is a script attached, which calls the rtcSin function, and
compares the result returned with the vbScript's own Sin function.
I can testify that the attached script works with win98se, but it
may take some "adjustments" to get it working with winXP...

If you read this far, you may have come to the (obvious) conclusion
that a vbScrpter would have no use for this, because all those
math functions are already available in vbScript. However, if you
poke around among the entry points of the dll's mentioned above,
you may find some intriguing entry points whose functionality is
available in vb, but _not_ in vbScript.

cheers, jw

p.s. Technical Factoid for Dynawrap fans. Initially this script
didn't work (gasp!). How could that happen? I know what you're
thinking: it was me -- Naw!!! It had to be dynawrap. Even
though I know nothing about c++, I combed through both DynaWrap
and DynaCall source looking for "something", and I found it.
Previously, I had thought that the "f" (for flag) input parameter
was strictly for telling DynaWrap what type of calling sequence
was used (_stdcall or _cdecl). However there are other flags.
More specifically, there is "4" for returning a "Math4" result,
and "8" for returning a "Math8" result. After some googling
and head-scratching, it became apparent that "VT_R8" (8 byte real),
variant type "Double", and "Math8" were all talking about THE
SAME THING(!). At least that's what I assumed. And so that
explains the previously questionable "f=s8" parameter, and
eventually how I got the rtcSin function to work with DynaWrap.



--------------090702000508020807070209
Content-Type: text/plain;
name="wshCallingRTCSinFunction_wDynawrap.vbs.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="wshCallingRTCSinFunction_wDynawrap.vbs.txt"

' wsh Test Calling the Math functions in vba5.dll, jw 16Sept06
'
' --- description block --------------------------
'
' Title: Test calling Math Functions (using Dynawrap)...
'
' Description: Motivated by a newsgroup posting, which asked about
' using the vbScript math functions in some other scripting
' language...
'
' Note that there are several (standard) dll's around
' containing math function entry points. Among these are
' vba5.dll and vba6.dll and the vb-runtimes (which you will
' have if you have any vb5 or vb6 apps installed on your
' system). You can also find the math functions in
' vbar332.dll, which you will have if you have VBA
' (Visual Basic for Applications) on your system.
'
' All of the above have the math functions: sine, cosine, tan,
' atan, Exp, Log, and so on, i.e., all the usual suspects...
'
' This script is only testing the sine function, but that
' should be enough to get you going...
'
' Author: mr_unreliable (all rights reserved)
' Website: none at this time (contact via: news://microsoft.public.scripting.vbscript)
'
' Usage: Use at you own risk, tested on win98se...
'
' Acknowledgments: none
'
' --- revision history ---------------------------
' 16Sept06: initial attempt
'
' --- end of description block -------------------

Option Explicit

Dim sSpace : sSpace = vbCrLf & vbCrLf
Dim sResults : sResults = "Results: " & sSpace ' initialize

Dim oDW ' as object
' Declare Function rtcSin Lib "msvbvm50.dll" (ByVal dblNumber As Double) As Double
Set oDW = CreateObject("DynamicWrapper") ' instantiate dynawrap
oDW.Register "MSVBVM50.DLL", "rtcSin", "i=d", "f=s8", "r=d" ' double parameter, and return value

Dim vntSine : vntSine = CDbl(0) ' initialize, type-cast as double...
vntSine = oDW.rtcSin(CDbl(1)) ' sine of one radian
' MsgBox("rtcSin returned a variant of type: " & TypeName(vntSine))
sResults = sResults & " rtcSin(1) returns: " & CStr(vntSine) & sSpace

vntSine = CDbl(0) ' reinitialize...
' call the vbs sine function, to cross-check the previous result...
vntSine = Sin(CDbl(1))
sResults = sResults & " vbsSin(1) returns: " & CStr(vntSine)

MsgBox sResults, vbInformation, " << texting rtcsine function >> "

Set oDW = nothing ' (may be omitted for those who trust microsoft implicitly)
WScript.Quit



--------------090702000508020807070209--

Re: using vbs math functions from another scripting language (take II)... by Justin

Justin
Mon Sep 18 13:09:59 CDT 2006

On Mon, 18 Sep 2006 11:08:09 -0500, mr_unreliable
<kindlyReplyToNewsgroup@notmail.com> wrote:

> In a previous posting, a scripter using scripting language other
> than vbScript, and further a language which has no math functions,
> and was wondering if there was some com object that would offer
> the capability of calling the vbs math functions.
>
> A previous response to that O.P. recommended installing the ms
> "Script Control", and place some vbScript coding inside the control
> to calculate the desired math functions.
>
> In addition to that, if you are courageous enough, or foolhardy enough,
> to call api's from script, then you can call the (vb) math functions
> directly. All you need is a relatively "light-weight" com control
> suitable for calling api's, which you could write yourself, or use
> one already available, like: "DynaWrap".

I wonder if any of VB's routines for compiling and executing p-code are
exposed in this manner. You could do some interesting (and probably
dangerous :) things with that.

--
Justin Piper
Bizco Technologies
http://www.bizco.com/

Re: using vbs math functions from another scripting language (take by mr_unreliable

mr_unreliable
Tue Sep 19 12:40:45 CDT 2006

This is a multi-part message in MIME format.
--------------030001090107060302000700
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Attached is a listing of the entry points in the
vb(6) runtimes dll.

Many, if not most are fairly understandable, from
the names given by microsoft.

I don't see anything related to p-code, but then
there are a number of _UN_ -named entry points
also, and so -- who knows what could be in there?

cheers, jw

Justin Piper wrote:
> I wonder if any of VB's routines for compiling and executing p-code are
> exposed in this manner. You could do some interesting (and probably
> dangerous :) things with that.
>
> --Justin Piper
> Bizco Technologies
> http://www.bizco.com/

--------------030001090107060302000700
Content-Type: text/plain;
name="vb(6)runtimes_EntryPoints.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="vb(6)runtimes_EntryPoints.txt"

__vbaAptOffset
__vbaAryConstruct
__vbaAryConstruct2
__vbaAryCopy
__vbaAryDestruct
__vbaAryMove
__vbaAryRebase1Var
__vbaAryRecCopy
__vbaAryRecMove
__vbaAryUnlock
__vbaAryVar
__vbaBoolStr
__vbaBoolVar
__vbaBoolVarNull
__vbaCastObj
__vbaCastObjVar
__vbaCheckType
__vbaCheckTypeVar
__vbaChkstk
__vbaCopyBytes
__vbaCopyBytesZero
__vbaCVarAryUdt
__vbaCyAbs
__vbaCyAdd
__vbaCyErrVar
__vbaCyFix
__vbaCyForInit
__vbaCyForNext
__vbaCyI2
__vbaCyI4
__vbaCyInt
__vbaCyMul
__vbaCyMulI2
__vbaCySgn
__vbaCyStr
__vbaCySub
__vbaCyUI1
__vbaCyVar
__vbaDateR4
__vbaDateR8
__vbaDateStr
__vbaDateVar
__vbaDerefAry
__vbaDerefAry1
__vbaEnd
__vbaErase
__vbaEraseKeepData
__vbaEraseNoPop
__vbaError
__vbaErrorOverflow
__vbaExceptHandler
__vbaExitEachAry
__vbaExitEachColl
__vbaExitEachVar
__vbaExitProc
__vbaFailedFriend
__vbaFileClose
__vbaFileCloseAll
__vbaFileLock
__vbaFileOpen
__vbaFileSeek
__vbaFixstrConstruct
__vbaForEachAry
__vbaForEachCollAd
__vbaForEachCollObj
__vbaForEachCollVar
__vbaForEachVar
__vbaFPException
__vbaFPFix
__vbaFPInt
__vbaFreeObjList
__vbaFreeStrList
__vbaFreeVarList
__vbaGenerateBoundsError
__vbaGet3
__vbaGet4
__vbaGetFxStr3
__vbaGetFxStr4
__vbaGetOwner3
__vbaGetOwner4
__vbaGosub
__vbaGosubFree
__vbaGosubReturn
__vbaHresultCheck
__vbaHresultCheckNonvirt
__vbaHresultCheckObj
__vbaI2Cy
__vbaI2ErrVar
__vbaI2ForNextCheck
__vbaI2Str
__vbaI2Var
__vbaI4Cy
__vbaI4ErrVar
__vbaI4ForNextCheck
__vbaI4Str
__vbaI4Var
__vbaInputFile
__vbaInStr
__vbaInStrB
__vbaInStrVar
__vbaInStrVarB
__vbaLateIdCall
__vbaLateIdCallLd
__vbaLateIdCallSt
__vbaLateIdNamedCall
__vbaLateIdNamedCallLd
__vbaLateIdNamedCallSt
__vbaLateIdNamedStAd
__vbaLateIdSt
__vbaLateIdStAd
__vbaLateMemCall
__vbaLateMemCallLd
__vbaLateMemCallSt
__vbaLateMemNamedCall
__vbaLateMemNamedCallLd
__vbaLateMemNamedCallSt
__vbaLateMemNamedStAd
__vbaLateMemSt
__vbaLateMemStAd
__vbaLbound
__vbaLdZeroAry
__vbaLenBstr
__vbaLenBstrB
__vbaLenVar
__vbaLenVarB
__vbaLineInputStr
__vbaLineInputVar
__vbaLsetFixstr
__vbaLsetFixstrFree
__vbaMidStmtBstr
__vbaMidStmtBstrB
__vbaMidStmtVar
__vbaMidStmtVarB
__vbaNameFile
__vbaNew
__vbaNew2
__vbaNextEachAry
__vbaNextEachCollAd
__vbaNextEachCollObj
__vbaNextEachCollVar
__vbaNextEachVar
__vbaObjAddref
__vbaObjIs
__vbaObjSet
__vbaObjSetAddref
__vbaObjVar
__vbaOnError
__vbaOnGoCheck
__vbaPowerR8
__vbaPrintFile
__vbaPrintObj
__vbaPut3
__vbaPut4
__vbaPutFxStr3
__vbaPutFxStr4
__vbaPutOwner3
__vbaPutOwner4
__vbaR4Cy
__vbaR4ErrVar
__vbaR4ForNextCheck
__vbaR4Sgn
__vbaR4Str
__vbaR4Var
__vbaR8Cy
__vbaR8ErrVar
__vbaR8FixI2
__vbaR8FixI4
__vbaR8ForNextCheck
__vbaR8IntI2
__vbaR8IntI4
__vbaR8Sgn
__vbaR8Str
__vbaR8Var
__vbaRaiseEvent
__vbaRecAnsiToUni
__vbaRecAssign
__vbaRecDestruct
__vbaRecDestructAnsi
__vbaRecUniToAnsi
__vbaRedim
__vbaRedimPreserve
__vbaRedimPreserveVar
__vbaRedimPreserveVar2
__vbaRedimVar
__vbaRefVarAry
__vbaResume
__vbaRsetFixstr
__vbaRsetFixstrFree
__vbaSetSystemError
__vbaStopExe
__vbaStr2Vec
__vbaStrAryToAnsi
__vbaStrAryToUnicode
__vbaStrBool
__vbaStrCat
__vbaStrCmp
__vbaStrComp
__vbaStrCompVar
__vbaStrCy
__vbaStrDate
__vbaStrFixstr
__vbaStrI2
__vbaStrI4
__vbaStrLike
__vbaStrR4
__vbaStrR8
__vbaStrTextCmp
__vbaStrTextLike
__vbaStrToAnsi
__vbaStrToUnicode
__vbaStrUI1
__vbaStrVarCopy
__vbaStrVarMove
__vbaStrVarVal
__vbaUbound
__vbaUdtVar
__vbaUI1Cy
__vbaUI1ErrVar
__vbaUI1Str
__vbaUI1Var
__vbaUnkVar
__vbaVar2Vec
__vbaVarAbs
__vbaVarAdd
__vbaVarAnd
__vbaVarCat
__vbaVarCmpEq
__vbaVarCmpGe
__vbaVarCmpGt
__vbaVarCmpLe
__vbaVarCmpLt
__vbaVarCmpNe
__vbaVarDateVar
__vbaVarDiv
__vbaVarEqv
__vbaVarErrI4
__vbaVarFix
__vbaVarForInit
__vbaVarForNext
__vbaVargObj
__vbaVargObjAddref
__vbaVargUnk
__vbaVargUnkAddref
__vbaVarIdiv
__vbaVarImp
__vbaVarIndexLoad
__vbaVarIndexLoadRef
__vbaVarIndexLoadRefLock
__vbaVarIndexStore
__vbaVarIndexStoreObj
__vbaVarInt
__vbaVarLike
__vbaVarLikeVar
__vbaVarMod
__vbaVarMul
__vbaVarNeg
__vbaVarNot
__vbaVarOr
__vbaVarPow
__vbaVarSetObj
__vbaVarSetObjAddref
__vbaVarSetUnk
__vbaVarSetUnkAddref
__vbaVarSetVar
__vbaVarSetVarAddref
__vbaVarSub
__vbaVarTextCmpEq
__vbaVarTextCmpGe
__vbaVarTextCmpGt
__vbaVarTextCmpLe
__vbaVarTextCmpLt
__vbaVarTextCmpNe
__vbaVarTextLike
__vbaVarTextLikeVar
__vbaVarTextTstEq
__vbaVarTextTstGe
__vbaVarTextTstGt
__vbaVarTextTstLe
__vbaVarTextTstLt
__vbaVarTextTstNe
__vbaVarTstEq
__vbaVarTstGe
__vbaVarTstGt
__vbaVarTstLe
__vbaVarTstLt
__vbaVarTstNe
__vbaVarXor
__vbaVerifyVarObj
__vbaWriteFile
_adj_fdiv_m16i
_adj_fdiv_m32
_adj_fdiv_m32i
_adj_fdiv_m64
_adj_fdiv_r
_adj_fdivr_m16i
_adj_fdivr_m32
_adj_fdivr_m32i
_adj_fdivr_m64
_adj_fpatan
_adj_fprem
_adj_fprem1
_adj_fptan
_allmul
_CIatan
_CIcos
_CIexp
_CIlog
_CIsin
_CIsqrt
_CItan
BASIC_CLASS_AddRef
BASIC_CLASS_GetIDsOfNames
BASIC_CLASS_Invoke
BASIC_CLASS_QueryInterface
BASIC_CLASS_Release
BASIC_DISPINTERFACE_GetTICount
BASIC_DISPINTERFACE_GetTypeInfo
CopyRecord
CreateIExprSrvObj
DllCanUnloadNow
DllFunctionCall
DllGetClassObject
DLLGetDocumentation
DllRegisterServer
DllUnregisterServer
EbCreateContext
EbDestroyContext
EbGetErrorInfo
EbGetHandleOfExecutingProject
EbGetObjConnectionCounts
EbGetVBAObject
EbIsProjectOnStack
EbLibraryLoad
EbLibraryUnload
EbLoadRunTime
EbResetProject
EbResetProjectNormal
EbSetContextWorkerThread
EVENT_SINK_AddRef
EVENT_SINK_GetIDsOfNames
EVENT_SINK_Invoke
EVENT_SINK_QueryInterface
EVENT_SINK_Release
EVENT_SINK2_AddRef
EVENT_SINK2_Release
GetMem1
GetMem2
GetMem4
GetMem8
GetMemEvent
GetMemNewObj
GetMemObj
GetMemStr
GetMemVar
IID_IVbaHost
MethCallEngine
ProcCallEngine
PutMem1
PutMem2
PutMem4
PutMem8
PutMemEvent
PutMemNewObj
PutMemObj
PutMemStr
PutMemVar
rtBoolFromErrVar
rtBstrFromErrVar
rtcAbsVar
rtcAnsiValueBstr
rtcAppActivate
rtcAppleScript
rtcArray
rtcAtn
rtcBeep
rtcBstrFromAnsi
rtcBstrFromByte
rtcBstrFromChar
rtcBstrFromError
rtcBstrFromFormatVar
rtcByteValueBstr
rtcChangeDir
rtcChangeDrive
rtcCharValueBstr
rtcChoose
rtcCommandBstr
rtcCommandVar
rtcCompareBstr
rtcCos
rtcCreateObject
rtcCreateObject2
rtcCurrentDir
rtcCurrentDirBstr
rtcCVErrFromVar
rtcDateAdd
rtcDateDiff
rtcDateFromVar
rtcDatePart
rtcDDB
rtcDeleteSetting
rtcDir
rtcDoEvents
rtcEndOfFile
rtcEnvironBstr
rtcEnvironVar
rtcErrObj
rtcExp
rtcFileAttributes
rtcFileCopy
rtcFileDateTime
rtcFileLen
rtcFileLength
rtcFileLocation
rtcFileReset
rtcFileSeek
rtcFileWidth
rtcFilter
rtcFixVar
rtcFormatCurrency
rtcFormatDateTime
rtcFormatNumber
rtcFormatPercent
rtcFreeFile
rtcFV
rtcGetAllSettings
rtcGetCurrentCalendar
rtcGetDateBstr
rtcGetDateValue
rtcGetDateVar
rtcGetDayOfMonth
rtcGetDayOfWeek
rtcGetErl
rtcGetFileAttr
rtcGetHostLCID
rtcGetHourOfDay
rtcGetMinuteOfHour
rtcGetMonthOfYear
rtcGetObject
rtcGetPresentDate
rtcGetSecondOfMinute
rtcGetSetting
rtcGetTimeBstr
rtcGetTimer
rtcGetTimeValue
rtcGetTimeVar
rtcGetYear
rtcHexBstrFromVar
rtcHexVarFromVar
rtcIMEStatus
rtcImmediateIf
rtcInputBox
rtcInputCharCount
rtcInputCharCountVar
rtcInputCount
rtcInputCountVar
rtcInStr
rtcInStrChar
rtcInStrRev
rtcIntVar
rtcIPMT
rtcIRR
rtcIsArray
rtcIsDate
rtcIsEmpty
rtcIsError
rtcIsMissing
rtcIsNull
rtcIsNumeric
rtcIsObject
rtcJoin
rtcKillFiles
rtcLeftBstr
rtcLeftCharBstr
rtcLeftCharVar
rtcLeftTrimBstr
rtcLeftTrimVar
rtcLeftVar
rtcLenCharVar
rtcLenVar
rtcLog
rtcLowerCaseBstr
rtcLowerCaseVar
rtcMacId
rtcMakeDir
rtcMidBstr
rtcMidCharBstr
rtcMidCharVar
rtcMidVar
rtcMIRR
rtcMonthName
rtcMsgBox
rtcNPer
rtcNPV
rtcOctBstrFromVar
rtcOctVarFromVar
rtcPackDate
rtcPackTime
rtcPartition
rtcPMT
rtcPPMT
rtcPV
rtcQBColor
rtcR8ValFromBstr
rtcRandomize
rtcRandomNext
rtcRate
rtcRemoveDir
rtcReplace
rtcRgb
rtcRightBstr
rtcRightCharBstr
rtcRightCharVar
rtcRightTrimBstr
rtcRightTrimVar
rtcRightVar
rtcSaveSetting
rtcSendKeys
rtcSetCurrentCalendar
rtcSetDateBstr
rtcSetDateVar
rtcSetFileAttr
rtcSetTimeBstr
rtcSetTimeVar
rtcSgnVar
rtcShell
rtcSin
rtcSLN
rtcSpaceBstr
rtcSpaceVar
rtcSplit
rtcSqr
rtcStrConvVar
rtcStrConvVar2
rtcStrFromVar
rtcStringBstr
rtcStringVar
rtcStrReverse
rtcSwitch
rtcSYD
rtcTan
rtcTrimBstr
rtcTrimVar
rtcTypeName
rtcUpperCaseBstr
rtcUpperCaseVar
rtcVarBstrFromAnsi
rtcVarBstrFromByte
rtcVarBstrFromChar
rtcVarDateFromVar
rtcVarFromError
rtcVarFromFormatVar
rtcVarFromVar
rtcVarStrFromVar
rtcVarType
rtcWeekdayName
rtCyFromErrVar
rtDecFromVar
rtI2FromErrVar
rtI4FromErrVar
rtR4FromErrVar
rtR8FromErrVar
rtUI1FromErrVar
SetMemEvent
SetMemNewObj
SetMemObj
SetMemVar
ThunRTMain
TipCreateInstanceEx
TipCreateInstanceProject2
TipGetAddressOfPredeclaredInstance
TipInvokeMethod
TipInvokeMethod2
TipSetOption
TipUnloadInstance
TipUnloadProject
VarPtr
VBDllCanUnloadNow
VBDllGetClassObject
VBDllRegisterServer
VBDllUnRegisterServer
Zombie_AddRef
Zombie_GetIDsOfNames
Zombie_GetTypeInfo
Zombie_GetTypeInfoCount
Zombie_Invoke
Zombie_QueryInterface
Zombie_Release

--------------030001090107060302000700--