Current location: Hot Scripts Forums » Programming Languages » Visual Basic » Return value from modal dialog?


Return value from modal dialog?

Reply
  #1 (permalink)  
Old 12-08-04, 03:14 PM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Return value from modal dialog?

I have the following code:

Dim dlgColorPicker As New frmColorPicker

dlgColorPicker.Show vbModal

Is there a way to get a value returned from the dialog? I want to know if the user pressed OK or Cancel. I know I can setup a global variable in frmColorPicker. Is this the only way?

Thanks,
Tim
Reply With Quote
  #2 (permalink)  
Old 12-10-04, 03:07 PM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up Solution

I found some slick code to accomplish this:


Calling module:
Code:
Dim dlgColorPicker As New frmColorPicker
Dim iRet as VbMsgBoxResult

    iRet = dlgColorPicker.ShowForm
In frmColorPicker:
Code:
Private m_ReturnVal as VbMsgBoxResult

Public Function ShowForm() As VbMsgBoxResult

    Me.Show vbModal
    ShowForm = m_ReturnVal

End Function

Private Sub cmdOK_Click()
    m_ReturnVal = vbOK
End Sub

Private Sub cmdCancel_Click()
    m_ReturnVal = vbCancel 
End Sub
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
calendar working until months changed bitesize JavaScript 1 01-13-04 01:50 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM
changing a specific dateformat in tigra bitesize JavaScript 0 10-30-03 08:58 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM


All times are GMT -5. The time now is 09:55 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.