Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Nick,
Yes, declare it the general section so it live as long as the form is loaded Dim numberOfTextBoxes As Long Private Sub UserForm_Initialize() Dim cntrl As Control For Each cntrl In Me.Controls If TypeName(cntrl) = "TextBox" And cntrl.Parent Is Frame1 Then numberOfTextBoxes = numberOfTextBoxes + 1 End If Next End Sub NickHK "Nick London" wrote in message ... Thanks! I seem however to have two problems. I thought I knew how to count the textboxes in a frame but I have a problem with my code: numberOfTextBoxes = StartPriceFrame.TextBoxes.Count It simple does not work. Do you perhaps know how to write the code for this? The second problem is that I need to use the value for the number of textboxes in another sub in the userform (e.g. there are five textboxes i.e. the number 5). But the varibale numberOfTextBoxes dies after the initialize sub. Can you send this variable along or should I declare it is a modular variable? I would be very thankful if you could help me with this! "NickHK" skrev: Nick, Yes, you would need code like: Private sub UserForm_Initialize() 'Code Here e.g. TextBox1.SetFocus End sub The _Initialize event is fired when the Userform is first shown and the _Activate event fires whenever the form receives focus. Check out the Help for (in English) "Understanding Objects, Properties, Methods, and Events" NickHK "Nick London" wrote in message ... Thank you. I am however not very accostomed to VB. How do you the UserForm_Activate() and UserForm_Initialize() ? Do you write: Private sub UserForm_Activate() .....count checkboxes End sub or how do you use it? Would be very much appreciated with help since I dont really know my way around these blocks.... "NickHK" skrev: The Userform has various events that you can respond to. I would UserForm_Activate() and UserForm_Initialize() are the ones you are looking for. NickHK "Nick London" wrote in message ... I have I user form that is shown when the user presses a button on a spreadsheet. The code in the spreasheet is: Public Sub startKnapp_Click() userForm1.Show End Sub Then the userform is shown. I want to do certain things when the userform is opened etc. count number of textboxes. How do you write code so that the program does certain things directly when the userform is opened i.e. the user shall not be forced to press a button or move the cursor over certain areas etc.? Please help me if you know how! Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Userform to enter values and shown in same userform in list | Excel Programming | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
Activating userform and filling it with data form row where userform is activate | Excel Programming | |||
Access from add_in userform to main template userform.... | Excel Programming | |||
Linking userform to userform in Excel 2003 | Excel Programming |