App Change question

  • Thread starter Thread starter Bryan Dickerson
  • Start date Start date
B

Bryan Dickerson

I had an app that started out as a regular Windows Application, but I
thought needed to be a Console Application (to run as a scheduled task), so
I tested and compiled it this way several times. Then I realized it didn't
need to be a Console App, but could be a regular Windows Application, so I
changed it back, but now my "status/progress" form doesn't display when I
test or run it. What did I do and how do I get my form to reappear?

TIA!
 
* "Bryan Dickerson said:
I had an app that started out as a regular Windows Application, but I
thought needed to be a Console Application (to run as a scheduled task), so
I tested and compiled it this way several times. Then I realized it didn't
need to be a Console App, but could be a regular Windows Application, so I
changed it back, but now my "status/progress" form doesn't display when I
test or run it. What did I do and how do I get my form to reappear?

In the project properties, you may want to set the project startup
object to your form.
 
The only problem there is that the form is not my start up object. I use
Sub Main to start it and the form is just a 'status', but I still would like
to see it (if I'm ever here at 2 am in the morning!) and it bothers me that
it's not. It's not affecting the execution of the program, but it's a
question that would like answered.
 
* "Bryan Dickerson said:
The only problem there is that the form is not my start up object. I use
Sub Main to start it and the form is just a 'status', but I still would like
to see it (if I'm ever here at 2 am in the morning!) and it bothers me that
it's not. It's not affecting the execution of the program, but it's a
question that would like answered.

Post the code of your 'Sub Main'. Are you sure the project compiles
cleanly?
 
Yes, I'm sure it compiles cleanly. It has been running for 2.5 weeks now.
=================================================
Public Shared Sub Main()

Dim oCon As New SourceConstants.srcConstants()
Dim oConnection As New srcConnection()
Dim oSInfo As New srcShippingInfo()
Dim fMsg As New frmMsg()

Try
fMsg.Message = "Setting Connection Parameters..."
With oConnection
.IPAddress = oCon.StarShip
.Cancel = False
.SystemUser = SourceLogins.srcSales
End With

With oSInfo
.Testing = (Microsoft.VisualBasic.Command <> vbNullString)
.Conn = oConnection
If Date.Today.DayOfWeek = DayOfWeek.Monday Then
.StartDate = Date.Today.AddDays(-2).ToShortDateString
fMsg.Message = "Retrieving Shipping information from Server
for Weekend."
Else
.StartDate = Date.Today.AddDays(-1).ToShortDateString
fMsg.Message = "Retrieving Shipping information from Server
for " & _
Date.Today.AddDays(-1).ToLongDateString
End If
.EndDate = Date.Today.AddDays(-1).ToShortDateString
.ReadData()
If .Results <> vbNullString Then
If CBool(InStr(.Results, "NO MATCH")) Then
.SendLog("No Orders found to confirm for date range: " &
..StartDate & " to " & .EndDate)
Else
fMsg.Hide()
.CreateEmails()
End If
End If
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
If oConnection.CheckForConnection Then oConnection.Disconnect()
End Try

End Sub
=================================================
fMsg is not the one I'm concerned about, but the form in the
"CreateEmails()" routine.
=================================================
Dim sData() As String
Dim sVals() As String
Dim sAddr() As String
Dim sLastAddr As String
Dim sMsg() As String
Dim Div As String = "; "
Dim i As Short
Dim j As Short
Dim iCnt As Short
Dim iMsgLine As Short = -1
Dim iSent As Short
Dim fM As New frmMain()
Dim eMail As New Mail.MailMessage()

Mail.SmtpMail.SmtpServer = SMTPSrv

Try
fM.PgmStatus = "Reading Shipping information from Server..."
sData = mvarResults.Split(oCon.AM)

fM.PgmStatus = "Creating and sending E-Mails..."
iCnt = sData.GetUpperBound(0)
fM.PBMax = CSng(iCnt + 1)
For i = 0 To iCnt
fM.PBVal = i + 1
Erase sVals
sVals = sData(i).Split(oCon.VM)
sVals(0) = Trim(sVals(0))
If sVals(0).EndsWith(oCon.SC) Then sVals(0) =
sVals(0).Remove(sVals(0).Length, 1)
If i > 0 Then
If sLastAddr.ToLower.Trim <> sVals(0).ToLower.Trim Then
eMail.Body = Join(sMsg, vbCrLf)
fM.PgmStatus = "Sending Email " & CStr(iSent + 1) & " to "
& sLastAddr
'--- Save a copy of the email, Send it and create a new
email object
Else
iMsgLine += 1
End If
Else
'--- Create first email object
End If
'--- Create the email msg text array
Next
eMail.Body = Join(sMsg, vbCrLf)
fM.PgmStatus = "Sending Email " & CStr(iSent + 1) & " to " &
sLastAddr
SaveMail(eMail)
If Not Testing Then Mail.SmtpMail.Send(eMail)
iSent += 1
fM.PgmStatus = iSent.ToString & " E-Mails sent."
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
fM.Finished = True
SendLog(fM.Log)
End Try
=================================================
You wanted to see code...

I know that the form is being created in memory, 'cause I take the text out
of the listbox on it and create a log email and I'm getting the log email
every morning. It's just that I never see the form when I test it from the
MDE and I've never seen it when I run tests of the program from the
scheduler. The only thing different there is that no actual emails are
being sent.
 
Back
Top