Source code for t-test, chi-square and anova in vbscript (ideally)

Posted on 2004-11-03
Last Modified: 2008-01-09

I am putting up a site that collects clinical data but the users want to get some simple looks at the data without exporting it to a statsitics package.

Does anyone know where I can get the source code (ideally in vbscript) for a t-test, chi-square and/or ANOVA?


Question by:levinho
    LVL 3

    Expert Comment

    Since you are using vbscript, presumably, you have access to Excel.
    If so, why not reference that application in vbs and use its statistcal functions (it has all the ones you need)?

    (Note: your Excel app needs the AnalysisToolPak referenced in the Addins collection.)


    Author Comment

    I appreciate the suggestion.  How would I go aboput doing that?

    Can you point me to an explaination of how to reference Excel using asp?


    LVL 3

    Accepted Solution

    I don't think you can reference APIs in vbs, but you could wrap this below into a dll, which you could call in vbs

    'Module declarations of API functions:
    Declare Function FindWindow Lib "user32" Alias _
      "FindWindowA" (ByVal lpClassname As String, ByVal lpWindowName As Long) As Long
    Declare Function SendMessage Lib "user32" Alias _
      "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
                      ByVal wParam As Long, lParam As Long) As Long
      Const WM_USER = 1024

    Function RefExcelApp () as object

        If AppDetect("Excel") > 0 Then
            Set RefExcelApp = GetObject(, "Excel.Application")
            Set RefExcelApp = CreateObject("Excel.Application")
          End If

    End sub

    Function AppDetect(strApplicationClassName As String) As Long
    'This procedure detects if an app is running and registers it.
      Dim hWnd As Long
      Dim lpClassname As String
      Select Case strApplicationClassName
        Case "CALC"
          lpClassname = "SciCalc"
        Case "NOTEPAD"
          lpClassname = "NOTEPAD"
        Case "EXCEL"
          lpClassname = "XLMAIN"
        Case "WORDPAD"
          lpClassname = "WordPadClass"
        Case "WORD"
          lpClassname = "OpusApp"
        Case "WINHELP"
          lpClassname = "MW_WINHELP"
        Case "PBRUSH"
          lpClassname = "MSPaintApp"
        Case "Explorer"
          lpClassname = "ieframe"
        Case Else
          lpClassname = strApplicationClassName
      End Select
      'This returns a valid handle number, or zero if app is not running
      hWnd = FindWindow(lpClassname, 0)
      AppDetect = hWnd
      If hWnd = 0 Then Exit Function
      SendMessage hWnd, WM_USER + 18, 0, 0   'app is running. Register it in the ROT
    End Function


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Introduction On a scale of 1 to 10, how would you rate our Product? Many of us have answered that question time and time again. But only a few of us have had the pleasure of receiving a stack of the filled out surveys and being asked to do somethi…
    Article by: Nicole
    This is a research brief on the potential colonization of humans on Mars.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now