Hi all I need a bit of help I don’t know what I am looking for, basically I want a rich text box to display public variables like (pizza toppings dinks ect that have been selected in other forms) these variables have declare in a module. But I want the rich text box to display these variables as soon as the screen loads ( a on form load event) if you know what I mean.

Recommended Answers

All 2 Replies

When you mean public variables they are global variables correct? You can make a Public Property to send over your variable over to the other form.

Public Propery pizza_toppings()
get
return pizzatoppings
end get

Set(ByVal value)
            pizzatoppings = value
        End Set

So you can set the value from other form by pizza_topping()='place here value of what user selected

Then on the other form that you want to display, you can do this richtextbox1=pizza_topping()

Also, see if this helps.

Public Class Form1
    Public topping1, topping2, drink As String '// Global declared Strings.
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// set values to your Strings.
        '//-- if needed to set from other Forms, use: Form1.topping1="topping here", etc.
        topping1 = "Cheese"
        topping2 = "Steak"
        drink = "Water"
        '// set the preset values in RichTextBox on Form1_Load, when Form Loads.
        RichTextBox1.Text = topping1 & vbNewLine & topping2 & vbNewLine & drink
    End Sub
End Class
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.