Results 1 to 6 of 6

Thread: returning a structure from a form

Threaded View

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved returning a structure from a form

    My code:
    VB Code:
    1. Private Sub SelectStrategy()
    2.         Dim f As New Strategies.SelectStrategyfrm      
    3.         f.ShowDialog()
    4.         If Not f.SelectedStrategy Is Nothing Then  '<====no good!!! ERROR! DANGER WILL ROBINSON!
    5. '                                                      the error is  'Is' requires operands that have
    6. '                                                        reference types, but this operand has the value type 'Globals.StrategyStruct'.
    7.             MyOptions.CurrentStrategy = f.SelectedStrategy
    8.         End If
    9.         f.Dispose()
    10.     End Sub
    My goal:
    The form being created prompts the user for information. If the user selects something a public structure is populated and the form closes, no problem. If however, the user selects Cancel, the public structure is set to Nothing and the form closes.
    VB Code:
    1. Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    2.         SelectedStrategy = Nothing
    3.         Me.Close()
    4.     End Sub

    But as you see in the first code segment, I have pointed out that I get an error.

    I don't understand the error. If I can use
    VB Code:
    1. SelectedStrategy = Nothing
    why can't I use
    VB Code:
    1. If Not f.SelectedStrategy Is Nothing Then
    and how do I propery do what I am trying to do?
    thanks
    kevin
    Last edited by kebo; Apr 14th, 2005 at 08:55 AM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width