store error messages

ram_Sathish

New Member
Joined
Jun 12, 2006
Messages
15
Hi All,

I tried storing the msgbox using the following code, but it did not work.
dim s
s=msgbox("Hi")

it return the s value as 1


I tried storing the error message which was declared (using msgbox) into excel file from vb application. But i could store it, it had open the excel application but i could not store the data into the sheets.

can any one please help me.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi Ram,

I'm not sure what you are trying to do here. Why do you want to store the MsgBox result?

What you are doing here is effectively doing a test.
s=MsgBox("Hi") will very likely evaluate as True, which is 1 in Excel.

If you can provide a bit more information on what you need to achieve, we will be able to help you.

Denis
 
Upvote 0
Ram

Like Denis I'm curious as to what you are actually wanting to do.

Could you explain further?

Denis

The code is not doing a comparison it's setting s to whatever value is returned by the message box.

In the OP's code the message box will only display the default OK button, vbOK = 1 so s = 1.

A better example might be this.
Code:
s = MsgBox("Hi", vbOKCancel)
MsgBox s
If you hit OK, s=1, if you hit Cancel it's 2.
 
Upvote 0
Hi Norie,

Yes I had forgotten about the MsgBox value returns. Thanks for the heads-up.

Denis
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top