We just got some code from a partner and since the app has a UI and we need to run it as a Windows Service I need to quickly update the code to A) Call "Sub Main" instead of directly loading the form, B) transfer all the form's code to a class, and C) keep the class alive until we want to kill it (Task Mgr, etc)
I know this is possible, and I'm sure I did it a few times (years ago) but I cannot remember how. When Sub Main completes the class terminates. How do I avoid this?
Thanks
Option Explicit
Private objRDSService As New clsRDSService
Sub Main()
Dim sSerialNumber As String
Dim sPassword As String
Dim sMenuFolder As String
Dim sOrderFolder As String
With objRDSService
.SerialNumber = sSerialNumber
.Password = sPassword
.OrderFolder = sOrderFolder
.SerialNumber = sSerialNumber
.MenuFolder = sMenuFolder
.LoginName = "Portal_" & Right("0000" & .SerialNumber, 3)
If .HasUI = True Then
frmMain.Show
'the following lines are commented out because I
'have not added the controls.
'frmMain.txtSerialNumber.text = .SerialNumber
'frmMain.txtMenuFolder.text = .MenuFolder
'frmMain.txtOrderFolder.text = .OrderFolder
'frmMain.txtStarted.text = .Started
End If
End With
End Sub
Question
James Rose
Hey gang,
We just got some code from a partner and since the app has a UI and we need to run it as a Windows Service I need to quickly update the code to A) Call "Sub Main" instead of directly loading the form, B) transfer all the form's code to a class, and C) keep the class alive until we want to kill it (Task Mgr, etc)
I know this is possible, and I'm sure I did it a few times (years ago) but I cannot remember how. When Sub Main completes the class terminates. How do I avoid this?
Thanks
Option Explicit Private objRDSService As New clsRDSService Sub Main() Dim sSerialNumber As String Dim sPassword As String Dim sMenuFolder As String Dim sOrderFolder As String With objRDSService .SerialNumber = sSerialNumber .Password = sPassword .OrderFolder = sOrderFolder .SerialNumber = sSerialNumber .MenuFolder = sMenuFolder .LoginName = "Portal_" & Right("0000" & .SerialNumber, 3) If .HasUI = True Then frmMain.Show 'the following lines are commented out because I 'have not added the controls. 'frmMain.txtSerialNumber.text = .SerialNumber 'frmMain.txtMenuFolder.text = .MenuFolder 'frmMain.txtOrderFolder.text = .OrderFolder 'frmMain.txtStarted.text = .Started End If End With End SubLink to comment
Share on other sites
4 answers to this question
Recommended Posts