LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 28 Jun 2000 12:49:13 GMT
Reply-To:   autretx@MY-DEJA.COM
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   autretx@MY-DEJA.COM
Organization:   Deja.com - Before you buy.
Subject:   Re: Using SAS.application object for VB

Look at the example 'oleauto1.exe' in your SAS paths

here s an example of the code:

VERSION 4.00 Begin VB.Form frmOLEAuto1 Caption = "OLEAUTO1 - SAS System OLE Automation Example 1" ClientHeight = 4215 ClientLeft = 990 ClientTop = 1725 ClientWidth = 9015 Height = 4905 Icon = "OLEAuto1.frx":0000 Left = 930 LinkTopic = "Form1" ScaleHeight = 4215 ScaleWidth = 9015 Top = 1095 Width = 9135 Begin VB.ListBox lbxText BeginProperty Font name = "SAS Monospace" charset = 0 weight = 400 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 3900 Left = 105 TabIndex = 7 Top = 120 Visible = 0 'False Width = 5790 End Begin VB.CommandButton pbExit Caption = "Exit" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 375 Left = 6120 TabIndex = 6 Top = 2280 Width = 2775 End Begin VB.PictureBox TrafficLight BackColor = &H0080FFFF& Height = 855 Left = 7320 ScaleHeight = 795 ScaleWidth = 315 TabIndex = 4 Top = 3000 Width = 375 Begin VB.Shape GreenLight FillColor = &H00008000& FillStyle = 0 'Solid Height = 255 Left = 30 Shape = 3 'Circle Top = 525 Width = 255 End Begin VB.Shape AmberLight FillColor = &H00004080& FillStyle = 0 'Solid Height = 255 Left = 30 Shape = 3 'Circle Top = 270 Width = 255 End Begin VB.Shape RedLight FillColor = &H00000080& FillStyle = 0 'Solid Height = 255 Left = 30 Shape = 3 'Circle Top = 15 Width = 255 End End Begin VB.CommandButton pbEndSAS Caption = "Terminate the SAS session" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 375 Left = 6120 TabIndex = 3 Top = 1560 Width = 2775 End Begin VB.CommandButton pbGetGraph Caption = "Retrieve Graph from SAS" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 375 Left = 6120 TabIndex = 2 Top = 1080 Width = 2775 End Begin VB.CommandButton pbStartSAS Caption = "Start the SAS System" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 375 Left = 6120 TabIndex = 0 Top = 120 Width = 2775 End Begin VB.CommandButton pbComputeHat Caption = "Compute the Graph" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 375 Left = 6120 TabIndex = 1 Top = 600 Width = 2775 End Begin VB.Label lblStatus Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "lblStatus" BeginProperty Font name = "MS Sans Serif" charset = 0 weight = 700 size = 8.25 underline = 0 'False italic = 0 'False strikethrough = 0 'False EndProperty Height = 255 Left = 6720 TabIndex = 5 Top = 3960 Width = 1575 End Begin VB.Image imgGraph BorderStyle = 1 'Fixed Single Height = 3975 Left = 120 Stretch = -1 'True Top = 120 Width = 5775 End Begin VB.Menu ID_FILE Caption = "&File" Begin VB.Menu ID_FILE_ABOUT Caption = "&About OLEAUTO1..." End Begin VB.Menu ID_SEP1 Caption = "-" End Begin VB.Menu ID_FILE_EXIT Caption = "E&xit" End End Begin VB.Menu ID_OPTIONS Caption = "&Options..." End End Attribute VB_Name = "frmOLEAuto1" Attribute VB_Creatable = False Attribute VB_Exposed = False Dim TestObj As Object

' Constants used with the ChangeLight subroutine Const RED = 1 Const AMBER = 2 Const GREEN = 3

' Store the initial control positions for resizing purposes ' later. Dim Right2BtnLeft As Integer Dim Right2PicLeft As Integer Dim Right2LblLeft As Integer Dim WidthNotImg As Integer Dim HeightNotImg As Integer Dim MinHeight As Integer Dim MinWidth As Integer

Private Sub Form_Resize() Dim AdjustFlag As Integer

' Set flag to check if we've had to adjust to a minimum size. AdjustFlag = False ' Check that the width is greater than our minimum width. If (frmOLEAuto1.Width < MinWidth) Then ' It isn't so adjust it. frmOLEAuto1.Width = MinWidth AdjustFlag = True End If ' Check that the height is greater than our minimum height. If (frmOLEAuto1.Height < MinHeight) Then ' It isn't so adjust it. frmOLEAuto1.Height = MinHeight AdjustFlag = True End If ' If we've had to make any adjustments then it's time to exit. If AdjustFlag = True Then Exit Sub End If ' No minimum sizing problems exist, so let's move the controls ' around to their new positions... pbStartSAS.Left = frmOLEAuto1.Width - Right2BtnLeft pbComputeHat.Left = pbStartSAS.Left pbGetGraph.Left = pbStartSAS.Left pbEndSAS.Left = pbStartSAS.Left pbExit.Left = pbStartSAS.Left TrafficLight.Left = frmOLEAuto1.Width - Right2PicLeft lblStatus.Left = frmOLEAuto1.Width - Right2LblLeft ' ... and adjust the width and height of imgGraph. imgGraph.Width = frmOLEAuto1.Width - WidthNotImg imgGraph.Height = frmOLEAuto1.Height - HeightNotImg lbxText.Width = imgGraph.Width lbxText.Height = imgGraph.Height End Sub

Private Sub ID_FILE_ABOUT_Click() ' Display the about dialog. frmAboutDlg.Show 1 End Sub

Private Sub ID_FILE_EXIT_Click() ' Allow exiting only if the Exit pushbutton is enabled. If pbExit.Enabled Then ' Exit using the Exit pushbutton click event handler. ' (This just saves maintaining duplicated code.) pbExit_Click End If End Sub

Private Sub ID_OPTIONS_Click() ' Display the Options dialog box. frmOptionsDlg.Show 1 If g_bSASActive Then TestObj.Visible = g_bVisible End If

End Sub

Private Sub pbComputeHat_Click() ' Diable all buttons while we do the processing. Call DisableAllButtons ' Set the traffic light to red again to indicate we're ' doing some work. Call ChangeLight(RED)

If g_nOutputType = 0 Then TestObj.Command ("OUTPUT;CLEAR") ' Submit some code to the SAS OLE object to generate a ' SAS data set with values to be charted. ' NOTE: Most of the lines of code below could have been ' concatenated into a single string and submitted ' in a single TestObj.Submit statement. TestObj.Submit ("DATA work.sales;") TestObj.Submit (" INPUT contnent & $12. value;") TestObj.Submit (" LABEL contnent='Continent'") TestObj.Submit (" value='Total Sales';") TestObj.Submit ("CARDS;") TestObj.Submit ("AUSTRALASIA 8764234") TestObj.Submit ("ASIA 1763855") TestObj.Submit ("EUROPE 3848956") TestObj.Submit ("AFRICA 819873") TestObj.Submit ("NTH AMERICA 6265823") TestObj.Submit ("STH AMERICA 987476") TestObj.Submit ("ANTARTICA 7846") TestObj.Submit (";") ' Now use PROC CHART to generate a simple text based ' horizontal bar chart. TestObj.Submit ("TITLE 'THE WACKY WOODEN WIDGET COMPANY';") TestObj.Submit ("TITLE2 'Worldwide Sales';") TestObj.Submit ("OPTIONS LINESIZE=70 PAGESIZE=32 NODATE NONUMBER;") TestObj.Submit ("PROC CHART DATA=work.sales;") TestObj.Submit (" HBAR contnent / SUMVAR=value;") TestObj.Submit ("RUN;") ElseIf g_nOutputType = 1 Then ' Submit some code to the SAS OLE object to generate a ' SAS data set with points to be plotted. ' NOTE: The lines of code below could have been ' concatenated into a single string and submitted ' in a single TestObj.Submit statement. TestObj.Submit ("DATA hat;") TestObj.Submit (" DO x=-5 TO 5 BY .25;") TestObj.Submit (" DO y=-5 TO 5 BY .25;") TestObj.Submit (" z = SIN(SQRT(x * x + y * y));") TestObj.Submit (" OUTPUT;") TestObj.Submit (" END;") TestObj.Submit (" END;") TestObj.Submit ("RUN;") ' Now use PROC G3D to generate the famous "Cowboy Hat" ' plot. TestObj.Submit ("TITLE 'Cowboy Hat';") TestObj.Submit ("PROC G3D DATA=work.hat;") TestObj.Submit (" PLOT y * x = z / CTOP=RED;") TestObj.Submit ("RUN;") TestObj.Submit ("QUIT;") End If ' Having generated the graph, only the Get Graph and ' End SAS buttons will be enabled. pbStartSAS.Enabled = False pbComputeHat.Enabled = False pbGetGraph.Enabled = True pbEndSAS.Enabled = True pbExit.Enabled = False Call EnableMenuBar(True, False, True) ' Move the Visual Basic keyboard focus on to the ' pbGetGraph button. pbGetGraph.SetFocus ' Show that we're ready to do something else by changing ' the traffic light back to green. Call ChangeLight(GREEN) End Sub

Private Sub pbEndSAS_Click() ' Diable all buttons while we do the processing. Call DisableAllButtons ' Shutdown the SAS session. TestObj.quit ' Delete the SAS OLE object. Set TestObj = Nothing ' SAS has now terminated. g_bSASActive = False ' Having shutdown the SAS session and deleted the OLE ' object, only the Start SAS and Exit buttons will be ' enabled. pbStartSAS.Enabled = True pbComputeHat.Enabled = False pbGetGraph.Enabled = False pbEndSAS.Enabled = False pbExit.Enabled = True Call EnableMenuBar(True, True, True) ' Set the Visual Basic keyboard focus to the pbExit ' button. pbExit.SetFocus End Sub

Private Sub Form_Load() ' By default we don't want the SAS Session visible g_bVisible = False ' The SAS session is not yet running g_bSASActive = False ' Set the default Output Type to text based graphics. g_nOutputType = 0 ' Initially show a green traffic light Call ChangeLight(GREEN) ' Initially, only the Start and Exit buttons will be ' enabled. pbStartSAS.Enabled = True pbComputeHat.Enabled = False pbGetGraph.Enabled = False pbEndSAS.Enabled = False pbExit.Enabled = True Call EnableMenuBar(True, True, True)

' Store the initial control positions for any adjustments ' needed due to resizing. Right2BtnLeft = frmOLEAuto1.Width - pbStartSAS.Left Right2PicLeft = frmOLEAuto1.Width - TrafficLight.Left Right2LblLeft = frmOLEAuto1.Width - lblStatus.Left WidthNotImg = frmOLEAuto1.Width - imgGraph.Width HeightNotImg = frmOLEAuto1.Height - imgGraph.Height MinHeight = frmOLEAuto1.Height MinWidth = frmOLEAuto1.Width

' Calculate and set the ListBox objects horizontal scroll ' extents. MainFont = frmOLEAuto1.Font MainScaleMode = frmOLEAuto1.ScaleMode frmOLEAuto1.Font = lbxText.Font frmOLEAuto1.ScaleMode = 3 ' Pixels rc = SendMessage(lbxText.hwnd, LB_SETHORIZONTALEXTENT, frmOLEAuto1.TextWidth(String(70, "H")), 0&) frmOLEAuto1.Font = MainFont frmOLEAuto1.ScaleMode = MainScaleMode End Sub

Private Sub pbGetGraph_Click() ' Diable all buttons while we do the processing. Call DisableAllButtons ' Indicate that we're currently busy. Call ChangeLight(RED) ' Determine which type of graphics are to be displayed. If g_nOutputType = 0 Then ' Issue the SAS commands to: ' 1/ make the OUTPUT window the currently active window ' 2/ move the cursor to row 1, column 1 ' 3/ begin marking text ' 4/ move the cursor (and marking) to the last column on ' on the last row ' 5/ end marking text ' 6/ copy the marked text to the Windows Clipboard. TestObj.Command ("OUTPUT;CURPOS 1 1;MARK;CURPOS MAX MAX;MARK;STORE")

' And now show our ListBox object... imgGraph.Visible = False lbxText.Visible = True

' Attempt to open the clipboard. If we can't then it's ' pointless to proceed any further, so we return a ' failure status. If Clipboard.GetFormat(CF_TEXT) Then TextBuffer = Clipboard.GetText(CF_TEXT)

i = 1 CurrChar = Left(TextBuffer, 1) szLine = "" While CurrChar <> Chr(0) And i <= Len(TextBuffer) If CurrChar = Chr(13) Or CurrChar = Chr(10) Then lbxText.AddItem szLine ' Reset the szLine string szLine = "" ' See if we have a CR/LF combination and if so ' bypass the LF character. If CurrChar = Chr(13) And Mid(TextBuffer, i + 1, 1) = Chr(10) Then i = i + 1 End If Else szLine = szLine + CurrChar End If i = i + 1 CurrChar = Mid(TextBuffer, i, 1) Wend End If ElseIf g_nOutputType = 1 Then ' Show our Image object... imgGraph.Visible = True lbxText.Visible = False ' Issue the SAS system command GSTORE to copy the contents ' of the SAS/GRAPH window to the Windows clipboard. TestObj.Command ("GRAPH1;GSTORE") ' Transfer the image from the Windows clipboard into the ' imgGraph image control. imgGraph.Picture = Clipboard.GetData() End If ' Having retrieved the graph, only the End SAS button ' will be enabled. pbStartSAS.Enabled = False pbComputeHat.Enabled = False pbGetGraph.Enabled = False pbEndSAS.Enabled = True pbExit.Enabled = False Call EnableMenuBar(True, False, True) ' Set the Visual Basic keyboard focus to the pbEndSAS ' button. pbEndSAS.SetFocus ' Show that we're now ready to do something else. Call ChangeLight(GREEN) End Sub

Private Sub pbExit_Click() ' Check if the user knows what they're doing. If (MessageBox(0, "Are you sure you want to exit?", "OLEAUTO1 - CONFIRM EXIT", MB_ICONQUESTION + MB_OKCANCEL) = IDOK) Then ' OK...let's shutdown the Visual Basic application End End If End Sub

Private Sub pbStartSAS_Click() ' Diable all buttons while we do the processing. Call DisableAllButtons ' Set the traffic light to red to indicate we're busy. Call ChangeLight(RED) ' Make the image object visible and empty, and the ' listbox object invisible and empty. lbxText.Clear lbxText.Visible = False imgGraph.Picture = LoadPicture() imgGraph.Visible = True ' Give the lights time to change rc = DoEvents ' Start the SAS System Set TestObj = CreateObject("SAS.Application.61102") ' SAS is now up and running. g_bSASActive = True ' Tell the SAS OLE server whether we want to see it. TestObj.Visible = g_bVisible TestObj.Wait = True ' Having started SAS, only the Compute Hat and End SAS ' buttons will be enabled. pbStartSAS.Enabled = False pbComputeHat.Enabled = True pbGetGraph.Enabled = False pbEndSAS.Enabled = True pbExit.Enabled = False Call EnableMenuBar(True, False, True) ' Move the Visual Basic keyboard focus to the ' pbComputeHat button. pbComputeHat.SetFocus ' Change the traffic light back to green (or ready). Call ChangeLight(GREEN) End Sub

Public Sub ChangeLight(LightOn As Integer) ' Define the traffic light color constants locally. Const lREDDULL = &H80& Const lREDGLOW = &HFF& Const lAMBERDULL = &H4080& Const lAMBERGLOW = &H80FF& Const lGREENDULL = &H8000& Const lGREENGLOW = &HFF00&

' Turn the appropriate light on, and the others off. Select Case (LightOn) Case (RED) RedLight.FillColor = lREDGLOW AmberLight.FillColor = lAMBERDULL GreenLight.FillColor = lGREENDULL lblStatus.Caption = "BUSY" Case (AMBER) RedLight.FillColor = lREDDULL AmberLight.FillColor = lAMBERGLOW GreenLight.FillColor = lGREENDULL lblStatus.Caption = "UNSURE" Case (GREEN) RedLight.FillColor = lREDDULL AmberLight.FillColor = lAMBERDULL GreenLight.FillColor = lGREENGLOW lblStatus.Caption = "READY" Case Else RedLight.FillColor = lREDDULL AmberLight.FillColor = lAMBERDULL GreenLight.FillColor = lGREENDULL lblStatus.Caption = "WHO KNOWS??" End Select End Sub

Public Sub DisableAllButtons() ' Disable all the buttons on the form while processing ' occurs. pbStartSAS.Enabled = False pbComputeHat.Enabled = False pbGetGraph.Enabled = False pbEndSAS.Enabled = False pbExit.Enabled = False Call EnableMenuBar(False, False, False) End Sub

Public Sub EnableMenuBar(bFileAbout As Integer, bFileExit As Integer, bOptions As Integer) ' Enable or disable the menu bar options ID_FILE_ABOUT.Enabled = bFileAbout ID_FILE_EXIT.Enabled = bFileExit ID_OPTIONS.Enabled = bOptions ' Give the menu a chance to redraw rc = DoEvents() End Sub

In article <017530ad.e401c015@usw-ex0104-031.remarq.com>, Vidya <vidya.chandrasekaranNOviSPAM@wipro.com.invalid> wrote: > I am trying to build a user friendly GUI in VB 6.0 for scoring > (I am refering to EMiner score node)a input dataset and printing > the target variable's score. > The problem i am facing is that i am unable to refer to > the "SAS.application" class. I could find windows registry entry > for the same class, but not in object browser of VB. > Could somebody help me! > > Thanx > Vidya > Wipro Technologies > Bangalore > India > > Got questions? Get answers over the phone at Keen.com. > Up to 100 minutes free! > http://www.keen.com > >

Sent via Deja.com http://www.deja.com/ Before you buy.


Back to: Top of message | Previous page | Main SAS-L page