#1
|
|||
|
|||
Help with VBA userform
Hello, so I am a student and I was asked to create a quiz for my IT project.
I wanted to add macros and so here is my problem. When I click start, I want a user form to pop up and ask for the users name, and store the input in the variable UserId. I have created the userform, and it works fine, but the variable doesn't seem to pick up what is written in the text box. Here is my code for this specific section: ------------------------------------------------------------------------ Private Sub TextBox1_Change() UserId = TextBox1.Text End Sub Private Sub ToggleButton1_Click() MsgBox ("Thank you," & UserId) End Sub ------------------------------------------------------------------------- Currently, the Thank you, & user ID currently reads Thank you,[BLANK] Thanks in advance for any help Kind regards, Benn |
#2
|
|||
|
|||
Although you haven't declared the variable (and you should) PowerPoint will assume it to be declared in the Private sub. Because it is private to this sub only it cannot be used elsewhere.
Declare it like this 'Outside iof the private sub Dim UserID As String Private Sub TextBox1_Change() UserID = TextBox1.Text End Sub Private Sub ToggleButton1_Click() MsgBox ("Thank you," & UserID) End Sub |
Tags |
help please, userform, vba code |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Keep Userform on Top | didjee | PowerPoint | 5 | 10-20-2014 02:22 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 |
Is it possible to take an input from a UserForm in one document to a UserForm in a do | BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |
Checkbox in Userform | lukael | Excel Programming | 5 | 02-18-2014 05:20 AM |
Userform Code not quite right - help please | vbanovice | Word VBA | 1 | 09-29-2013 09:20 PM |