开发者

In VB6 is there something similar to DialogResult from a dialog?

开发者 https://www.devze.com 2023-03-24 19:22 出处:网络
I have a VB6 form with buttons with the text \'Continue\' and \'Cancel\'. I want to check which one was clicked. In C# every form has a dialog result and I could set it before exiting the form dependi

I have a VB6 form with buttons with the text 'Continue' and 'Cancel'. I want to check which one was clicked. In C# every form has a dialog result and I could set it before exiting the form depending on which button was clicked. I don't see this in VB6.

Is there a dialog result? If not what is the best practice for checking the dialog r开发者_开发百科esult?


To simulate the .net WinForms behaviour, you will need a helper function in your form's code:

Public Function ShowDialog() As VbMsgBoxResult
  Me.Show vbModal
  ShowDialog = Iif(Cancelled, vbCancel, vbOk)
  Unload Me
End Function

The form level Cancelled variable can be set by the button event functions before calling .Hide() or .Close(), or you could have a variable containing the result code directly.


In VB6 a dialog generally returns an integer value, which may correspond to vbYes, vbNo, vbCancel, etc. See this article for details: http://www.vb6.us/tutorials/understanding-msgbox-command-visual-basic

http://www.code-vb.com/fragments/Dialogs.htm#Msgbox OK-Cancel

You'll have to specify it on your form if you've created the form yourself.

The last answer in this post has a hint that may help: http://www.xtremevbtalk.com/archive/index.php/t-306663.html

0

精彩评论

暂无评论...
验证码 换一张
取 消