Creating Customized Dialog Boxes Advanced Controls in Hindi
Makhanlal Chaturvedi University / BCA / VBA programming
Customized Dialog Boxes and Advanced ActiveX Controls in Hindi
Creating Customized Dialog Boxes Advanced Controls in Hindi
What is a Customized Dialog Box?
Customized Dialog Box एक ऐसा User Interface होता है जो User से Input लेने, कोई सूचना देने या किसी कार्य को नियंत्रित करने के लिए बनाया जाता है। ये Predefined Dialog Boxes जैसे MsgBox और InputBox से अलग होते हैं क्योंकि इन्हें हम User की आवश्यकता के अनुसार Design करते हैं।
Why Use Customized Dialog Boxes?
- Multiple Input Fields (TextBox, CheckBox, OptionButton) का उपयोग करने के लिए
- Better User Interface बनाने के लिए
- Specific Data Validation लागू करने के लिए
- Professional और Interactive Experience देने के लिए
How to Create a Customized Dialog Box
- Step 1: Visual Basic Editor (VBE) में जाएं (Alt + F11 दबाएं)
- Step 2: Insert → UserForm चुनें
- Step 3: Toolbox से Controls जैसे TextBox, CommandButton, Label इत्यादि को Form पर Drag करें
- Step 4: Controls को Arrange करें और Proper Name दें
- Step 5: Code Editor में जाकर Events को Handle करें
Basic Example of Customized Dialog Box
Private Sub CommandButton1_Click()
MsgBox "Welcome " & TextBox1.Value
End Sub
Adding Text Boxes and Frames in User Forms in Hindi
What is a TextBox?
TextBox एक ऐसा Control होता है जहां User Text Input कर सकता है। User से नाम, ईमेल या कोई भी जानकारी लेने के लिए इसका उपयोग किया जाता है।
Adding a TextBox to UserForm
- Toolbox से TextBox आइकन चुनें
- UserForm पर क्लिक करके उसे रखें
- Properties Window में Name और Font जैसी Properties सेट करें
What is a Frame?
Frame एक Grouping Control होता है जिसका उपयोग एक से अधिक Controls को Logical Group में दिखाने के लिए किया जाता है। जैसे अगर एक Section में Gender से संबंधित OptionButtons हैं तो उन्हें एक Frame में रखें।
Adding a Frame to UserForm
- Toolbox से Frame चुनें
- UserForm पर Drag करें
- OptionButtons या अन्य Controls को Frame के अंदर रखें
Example: Frame with Gender Selection
If OptionButton1.Value = True Then
gender = "Male"
ElseIf OptionButton2.Value = True Then
gender = "Female"
End If
Enhancing Functionality with Advanced ActiveX Controls in Hindi
What are ActiveX Controls?
ActiveX Controls वे Components होते हैं जिन्हें Microsoft ने बनाया है ताकि हम Interactive Features जैसे Calendar, Date Picker, Progress Bar आदि को UserForm में उपयोग कर सकें।
Common ActiveX Controls
- ComboBox
- ListBox
- SpinButton
- ScrollBar
- Calendar Control
Adding and Configuring ActiveX Controls
- Developer Tab → Insert → ActiveX Controls से चुनें
- UserForm पर Drag करें
- Properties से Customize करें जैसे Name, Font, List Items
Code Example: ComboBox में Items जोड़ना
Private Sub UserForm_Initialize()
ComboBox1.AddItem "India"
ComboBox1.AddItem "USA"
ComboBox1.AddItem "UK"
End Sub
Code Example: ScrollBar से Value Control करना
Private Sub ScrollBar1_Change()
TextBox1.Text = ScrollBar1.Value
End Sub
Practical Examples of Customized Dialog Boxes in Hindi
Example 1: Login Dialog Box
- Username और Password TextBoxes
- Login और Cancel Buttons
Private Sub CommandButton1_Click()
If TextBox1.Value = "admin" And TextBox2.Value = "1234" Then
MsgBox "Login Successful"
Else
MsgBox "Invalid Credentials"
End If
End Sub
Example 2: Data Entry Form
- Name, Age, Gender Fields
- Submit Button जो Sheet में Data Store करता है
Private Sub SubmitButton_Click()
Dim row As Integer
row = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheet1.Cells(row, 1).Value = TextBox1.Value
Sheet1.Cells(row, 2).Value = TextBox2.Value
Sheet1.Cells(row, 3).Value = IIf(OptionButton1.Value, "Male", "Female")
MsgBox "Data Saved Successfully"
End Sub
Example 3: Date Picker with Calendar Control
- Calendar Control का उपयोग करें
- Selected Date को TextBox में Show करें
Private Sub Calendar1_Click()
TextBox1.Text = Calendar1.Value
End Sub
Example 4: Auto Filling ComboBox
- City या Country का DropDown जो Sheet से Auto Fill होता है
Private Sub UserForm_Initialize()
Dim lastRow As Integer, i As Integer
lastRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
ComboBox1.AddItem Sheet1.Cells(i, 1).Value
Next i
End Sub
Table: Comparison between MsgBox, InputBox and UserForm
| Feature | MsgBox | InputBox | UserForm |
|---|---|---|---|
| Multiple Inputs | ❌ | ❌ | ✅ |
| UI Customization | ❌ | ❌ | ✅ |
| Advanced Controls | ❌ | ❌ | ✅ |
| Data Validation | ❌ | ✅ | ✅ |
Final Tips for Students
- UserForm का उपयोग करके अपने Excel Projects को Professional बनाएं
- Code लिखने से पहले हमेशा Plan करें कि किस Input की जरूरत है
- Testing हर Stage पर करें ताकि कोई Error ना रहे
- Controls का Proper नामकरण करें जैसे TextBox1 को txtName या txtAge
FAQs
ComboBox1.AddItem "India"इस तरह आप कई Items ComboBox में जोड़ सकते हैं।