Private Sub cmdSave_Click() Dim Answer As VbMsgBoxResult If lstYours.ListCount = -0 Then MsgBox "Cannot save or send as you have nothing in your list.", vbOKOnly + vbExclamation, "Sorry!" Else Answer = "InputBox2" YourFile = InputBox2("Please enter your name:" & vbCrLf & "Thanks!" & vbCrLf & "This will help me determine who's list I am looking at.", "FileName", "EnterNameHere") If InputBox2 = vbOK Then Dim NextItem As Long Open "E:\" & YourFile & ".txt" For Append As #1 ' Loop through the items in the listbox For NextItem = 0 To lstYours.ListCount - 1 ' Write to the file the item text Print #1, lstYours.List(NextItem) Next Close #1 ' Log into the E-Mail server EMailSession.SignOn EMailMessage.SessionID = EMailSession.SessionID ' Create the Message EMailMessage.Compose EMailMessage.RecipAddress = "email@example.com" EMailMessage.RecipDisplayName = "freddy" EMailMessage.MsgSubject = "Here is " & YourFile & "'s list they sent." EMailMessage.MsgNoteText = "Hello Freddy, here is my list." & vbCrLf & "Talk Soon!!" EMailMessage.AttachmentPathName = "E:\" & YourFile & ".txt" ' Send the Message EMailMessage.Send ' Log Off the E-Mail Server EMailSession.SignOff MsgBox "Your list has been sent to the Programmer (freddy)." & vbCrLf & "Thankyou!", vbOKOnly + vbExclamation, "E-Mail Sent!" Else MsgBox "You Canceled", vbOKOnly, "Canceled" End If End If End Sub
Okay, from the code above what i am trying to do is tell the program that if the user clicks cancel in the inputbox it tells them that they canceled the operation and will not send the e-mail.
Problem is ... cannot work it out. any help is always appreciated.
P.S - i need the YourFile in front of the inputbox as that is a global string used throughout the program.
I am using VB6
This post has been edited by PNJLj: 23 June 2009 - 01:02 AM