How to Pass UserFrom1 Variables to UserFrom Form 2

Asked 2 years ago, Updated 2 years ago, 310 views

When I click CommandButton1 in UserFrom1, I put 10 in variable A (variable A is public variable). What code would it be to display UserFrom2 in UserFrom2.Show and MsgBox in UserFrom2 to display the contents of variable A?

Currently, the program in UserFrom2 says MsgBox UserFrom1.A, but 10 is not displayed.

vba

2022-09-30 22:03

1 Answers

I don't know when to call UserFrom2, but
When I tried using this code, I pressed the UserFrom2 button to see the value in UserFrom1.A.

UserFrom1

Option Explicit
Public As String
Private Sub CommandButton1_Click()
    A = 10
    UserFrom 2.Show
End Sub

UserFrom 2

Option Explicit
Private Sub CommandButton1_Click()
    MsgBox UserFrom 1.A
End Sub


2022-09-30 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.