I have been used to creating subroutines or functions that can be called multiple times within applications with different parameters.
In the code below, all I want to do is get the result of a dialog that the user answers yes or no to.
'I have not found a way to call a sub or function trying to return something with a wait for in it
'as soon as it hits the wait for it returns to the calling routine before the result to be obtained in the
'sub can be obtained so the result. An example is this dialog routine
'this code works as long as I leave it under the button click. I could use it everytime I needed input from the user, but it seems like I
'should be able to write a function to do it and return a value.
'*******************************************************
'private Sub Button1_Click
' Dim SF As Object
' Dim bm As Bitmap
'
' bm.Initialize(File.DirAssets,"good.ico")
' Dim SF As Object = xui.Msgbox2Async("Test Message", "Test Title", "OK", "Cancel", "No", bm)
' Wait For (SF) Msgbox_Result (Result As Int)
'
' If Result = DialogResponse.POSITIVE Then
' xui.MsgboxAsync("Yes Selected", "Result Messagebox")
' else If Result = DialogResponse.NEGATIVE Then
' xui.MsgboxAsync("No Selected", "Result Messagebox")
' else if Result = DialogResponse.CANCEL Then
' xui.MsgboxAsync("Cancel Selected", "Result Messagebox")
' End If
'end sub
'******************************************************
But I would like to do the same thing by creating as sub/function that I can pass the Title and text for the
dialog and call it whenever I wanted and retrieve the result provided by the user to do something
I have tried a number of things but no success. My latest attempt is below
I tried to put this in a function that I could call
Type StrRef (s As Int) ***declared in Class Globals as I hoped I could get the result back by ref.
'Calling Routine
'******************************************
dim xx as strRef
xx.s = 99
'DialogOK("TestTitle", "Test Message", xx)
'***Here I just want to do one thing if the user selected "OK" and another if they selected "NO"
'***I had hoped XX would have come back with the result (Yes or No) but it does not.
Private Sub DialogOK (Title As String, Message As String, inx As StrRef) As ResumableSub
Dim SF As Object
Dim bm As Bitmap
bm.Initialize(File.DirAssets,"good.ico")
Dim SF As Object = xui.Msgbox2Async(Message, Title, "OK", "", "No", bm)
Wait For (SF) Msgbox_Result (Result As Int)
inx.s = Result
Return Result
'
End Sub
I never get a result back apparently because as soon as the wait for is encountered, it exits the sub without giving me anything back
I would appreciate any help.
Thank you
In the code below, all I want to do is get the result of a dialog that the user answers yes or no to.
'I have not found a way to call a sub or function trying to return something with a wait for in it
'as soon as it hits the wait for it returns to the calling routine before the result to be obtained in the
'sub can be obtained so the result. An example is this dialog routine
'this code works as long as I leave it under the button click. I could use it everytime I needed input from the user, but it seems like I
'should be able to write a function to do it and return a value.
'*******************************************************
'private Sub Button1_Click
' Dim SF As Object
' Dim bm As Bitmap
'
' bm.Initialize(File.DirAssets,"good.ico")
' Dim SF As Object = xui.Msgbox2Async("Test Message", "Test Title", "OK", "Cancel", "No", bm)
' Wait For (SF) Msgbox_Result (Result As Int)
'
' If Result = DialogResponse.POSITIVE Then
' xui.MsgboxAsync("Yes Selected", "Result Messagebox")
' else If Result = DialogResponse.NEGATIVE Then
' xui.MsgboxAsync("No Selected", "Result Messagebox")
' else if Result = DialogResponse.CANCEL Then
' xui.MsgboxAsync("Cancel Selected", "Result Messagebox")
' End If
'end sub
'******************************************************
But I would like to do the same thing by creating as sub/function that I can pass the Title and text for the
dialog and call it whenever I wanted and retrieve the result provided by the user to do something
I have tried a number of things but no success. My latest attempt is below
I tried to put this in a function that I could call
Type StrRef (s As Int) ***declared in Class Globals as I hoped I could get the result back by ref.
'Calling Routine
'******************************************
dim xx as strRef
xx.s = 99
'DialogOK("TestTitle", "Test Message", xx)
'***Here I just want to do one thing if the user selected "OK" and another if they selected "NO"
'***I had hoped XX would have come back with the result (Yes or No) but it does not.
Private Sub DialogOK (Title As String, Message As String, inx As StrRef) As ResumableSub
Dim SF As Object
Dim bm As Bitmap
bm.Initialize(File.DirAssets,"good.ico")
Dim SF As Object = xui.Msgbox2Async(Message, Title, "OK", "", "No", bm)
Wait For (SF) Msgbox_Result (Result As Int)
inx.s = Result
Return Result
'
End Sub
I never get a result back apparently because as soon as the wait for is encountered, it exits the sub without giving me anything back
I would appreciate any help.
Thank you