Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-25-2021, 11:00 PM
Justice Justice is offline Userform variables in another module Windows 10 Userform variables in another module Office 2016
Novice
Userform variables in another module
 
Join Date: Aug 2021
Posts: 2
Justice is on a distinguished road
Default Userform variables in another module

Hey fellow coders,

i am having a problem concerning my UserForm. I don't know what to do.

In my main module I have a procedure that does different things. It should react accordingly to which button is clicked on the userform.

What I have:

I have my userform with two buttons and the following code:

Code:
Private Sub UserForm_Initialize()
    Dim iAnswer, iA, iB As Integer
End Sub

Private Sub CommandButtonA_Click()
    iAnswer = iA
    Unload Me
End Sub

Private Sub CommandButtonB_Click()
    iAnswer = iB
    Unload Me
End Sub
And I have a module with loads of subprocedures. One of them looks like that:

Code:
Sub main()

Dim iAnswer, iA, iB As Integer

(... code ....)

If CheckUp.Installed Then

    UserForm1.Show vbModeless
    
End If

If iAnswer = iA Then
          "do this and that"
ElseIf iAnswer = iB Then
          "do this and that"
Else
          "do that"
End If

End Sub
Problem:

The Macro doesn't react to which button is clicked. It just proceeds the first if-case. I guess this is because the variables from the UserForm don't get transported over to the module.

How can I solve that?

(Sorry if it is difficult to understand. English isn't my native language...)



Thank you so much!
Justice
Reply With Quote
  #2  
Old 08-26-2021, 12:56 AM
Justice Justice is offline Userform variables in another module Windows 10 Userform variables in another module Office 2016
Novice
Userform variables in another module
 
Join Date: Aug 2021
Posts: 2
Justice is on a distinguished road
Default Solved

Thanks guys, I solved it on my own!
Reply With Quote
Reply

Tags
userform

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array to iterate through variables and trap blank variables Marrick13 Word VBA 5 08-04-2015 06:19 AM
can word: make variables, find appropriate pages, fill out pages with variables, print only those 20GT Word VBA 1 10-15-2014 09:48 PM
VBA Code in a UserForm module to delete a Command Button which opens the userform Simoninparis Word VBA 2 09-21-2014 03:50 AM
Userform variables in another module Help with a drop down in userform and variables leemoreau Word VBA 1 09-14-2013 06:01 AM
AZWizard Module - ?hidden module pcaldwell Word 1 08-22-2012 01:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft