VB help.....EASY for an expert :)

CougarGT

Junior Member
Feb 5, 2002
16
0
0
This should be an easy one for someone that has done some VB before. I have really never used it VB since I use C++ and Java.
I have a method called:

HRESULT Initialize()
params: none
return: S_OK - success
F_FAIL - Failure

This method opens a connection to a message display (i already have the message display control installed and added to the project)
This project is in Excel. What i am trying to do is open the connection to the display, and then determine if it was a success or a failure. I would like to update a cell in the spreadsheet with a 0 or a 1 according to what the return value is. Here is what i have:

Private Sub CommandButton1_Click()

InViewCtrl1.Initialize ' Opens coms to the display

If Initialize = E_FAIL Then
Sheet1.Cells(1, 1) = 0
End If

If Initialize = S_OK Then
Sheet1.Cells(1, 1) = 1
End If

InViewCtrl1.AddMessage (1) 'Adds message #1 to the displays queue

InViewCtrl1.Close 'Closes coms to the display

End Sub

The problem i have is weather or not the connection was successful it always displays a 1. (I have forced connection failures by unplugging the display)
Any ideas?

Thanks,
Matt
 

AlricTheMad

Member
Jun 25, 2001
125
0
0
Not sure if this is the problem but, you evaluate initialize twice.

You might want to try an if/then structure.

Also send a message to the anothe cell in ech part of the evaluation. that way you will be sure that all the appropriate steps are taken

AlricTheMad