vbYesNo Message Box
Hi All,
A very simple question, I have a msgbox which gives a user the option to save file to Floppy Disk YES or NO.
MsgBox "Please insert Floppy Disk:?", vbYesNo, "Export"
FileCopy "d:\tmp\Test1.txt", "a:\data_" & Format(Now, "yyyy-mm-dd HhNn") & ".txt"
From the above code it would copy the file even if the user selected the option NO.
Not sure how to write a loop, i.e :confused: .
if vbYesNo = Yes then
FileCopy "d:\tmp\Test1.txt", "a:\data_" & Format(Now, "yyyy-mm-dd HhNn")
end if
[547 byte] By [
mp_direct] at [2007-11-11 7:13:07]

# 2 Re: vbYesNo Message Box
Hi try this
I was just working on a message box so I still had the code fresh in my mind :)
hope that helps
Drew
Dim Example As Integer
Example = MsgBox "Please insert Floppy Disk:?", vbYesNo, "Export")
If Example = VbYes Then
FileCopy "d:\tmp\Test1.txt", "a:\data_" & Format(Now, "yyyy-mm-dd HhNn") & ".txt"
end if
If Example = VBNo Then
' what ever you want to do with a no reponse
End If
# 3 Re: vbYesNo Message Box
The only way I would change Drew's example is to declare the Example variable as VbMsgBoxResult rather than Integer (and give it a more meaningful name ;-):
Dim Response As VbMsgBoxResult
Response = MsgBox ...
If Response = vbYes...
# 4 Re: vbYesNo Message Box
'Try this...
Dim Answer as integer
Answer=Msgbox("Your prompt",vbyesno,"Your title")
'if Answer = 6
'then
'Answer = vbyes
'if Answer = 7
'then
'Answer = vbno
.
# 5 Re: vbYesNo Message Box
Or simply ...
If MsgBox ("Please insert Floppy Disk:?", vbYesNo + vbQuestion, "Export") = VbYes Then
FileCopy "d:\tmp\Test1.txt", "a:\data_" & Format(Now, "yyyy-mm-dd HhNn") & ".txt"
Else
'The user selected 'No'
End If
Note the '+ vbQuestion' - this gives a 'big' question mark on your message box.
With Drew's example, the 'If Then' for 'Yes' should have an 'Else' instead of another 'If' following the first one ... ;-)
gupex at 2007-11-11 17:31:28 >
