I have two forms. First form has 5 buttons, when all 5 buttons are clicked they should display another form, however depending on which button is clicked different text and images are displayed through a select case statement. However I am not sure what links this to the first form to display the right text and image. Here is my code for the second form:

Imports System.IO
Public Class frmCandidate

Inherits System.Windows.Forms.Form
Public Shared Pic As PictureBox

Dim myStream As Stream

Private Sub frmCan_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Dim count As Integer

Class1.strName(0) = "Dog"
Class1.strName(1) = "Alien"
Class1.strName(2) = "Lobster"
Class1.strName(3) = "smurf"
Class1.strName(4) = "yellowstar"

Me.Label1.Text = Class1.strName(count)

Select Case Class1.strName(count)
Case "Dog"
Me.PictureBox1.Image = My.Resources.dog
myStream = File.Open("C:\dog.txt", FileMode.OpenOrCreate)
Case "Alien"
Me.PictureBox1.Image = My.Resources.greenalien
Case "Lobster"
Me.PictureBox1.Image = My.Resources.lobster
Case "Smurf"
Me.PictureBox1.Image = My.Resources.smurf
Case "Star"
Me.PictureBox1.Image = My.Resources.yellowstar
End Select
End Sub

End Class

You should add an extra property for your second Form. When you are opening your second form, you can set the property, and get the property when your second form is opened.

Here is your second form:

Public Class second_form

    Dim link As String = ""
    Public WriteOnly Property link() As String
        Set(ByVal value As String)
            link = value
        End Set
    End Property

'Here are your code, events etc...

End Class

And here is your first Form when open the second form:

Dim newform As New second_form
newform.link = "something from your first form"
newform.ShowDialog()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.