none
Trouble populating a Dialogue Box RRS feed

  • Question

  • I have a dialogue box to open and then populate it with some information.  The following works fine:

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim dlg As dlg_param_details = Nothing
    
            dlg = New dlg_param_details
    
            dlg.txtbx_1.Text = "bananas"
    
            If dlg.ShowDialog = DialogResult.OK Then
    
            End If
        End Sub

    As there is a lot to populate in the dialogue box Id like to seperate it into a seperate sub a bit like this:

        Sub populate(text_to_populate, dlg)
            dlg.txtbx_1.Text = "bananas"
        End Sub
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim dlg As dlg_param_details = Nothing
    
            dlg = New dlg_param_details
    
            populate("bananas", dlg)
    
            If dlg.ShowDialog = DialogResult.OK Then
    
            End If
        End Sub

    However, when I run it, I get the message

    Exception Unhandled:

    System.MissingMemberException: 'Public member 'txtbx_1' on type 'dlg_param_details' not found.'

    Can anyone help on how to pass a dialogue box into a sub correctly??

    Monday, September 16, 2019 3:53 PM

Answers

  • Do you have Option Strict On ? If not do so in the same class or module or form this code is having an issue as the fits line in the file.

    Also try

    Sub populate(text_to_populateAs String, dlg As dlg_param_details)
    dlg.txtbx_1.Text = "bananas"
    End Sub


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Monday, September 16, 2019 4:15 PM
    Moderator

All replies

  • Do you have Option Strict On ? If not do so in the same class or module or form this code is having an issue as the fits line in the file.

    Also try

    Sub populate(text_to_populateAs String, dlg As dlg_param_details)
    dlg.txtbx_1.Text = "bananas"
    End Sub


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Monday, September 16, 2019 4:15 PM
    Moderator
  • Hi

    Please show the code where

    dlg_param_details

    is declared.

    Is it a Form you have designed for the Input or a System Dialog?


    Regards Les, Livingston, Scotland

    Monday, September 16, 2019 4:15 PM