How can design my own Form
Posted by A.Hayi Masnoor on January 21, 2002 11:56 PM
Hi,
How can i make a form of my own.
Is its coding resembles VB?
Bye
Hayi
www.geocities.com/hayi2k/A_Hayi_Mansoor.html
Posted by Joe Was on January 22, 2002 8:56 AM
In the VB editor menue select "Insert" select User Form, then use the toolbox to populate the form with tools. Right click a tool select properties and then build the code. That is what you whant the tool (control) to do, like a button to activate a sheet macro or a checkbox to lode a switch. JSW
Posted by A. Hayi on January 22, 2002 9:10 PM
Hi,
I want to create a form in Excell, I know how to program vb. The thing which i want to know is Excell's coding resembles that of VB?
Regards,
Hayi
Posted by Joe Was on January 23, 2002 5:58 AM
The code looks the same, but most are done in parts. You may need conventional code to call the form, below is all the code to pull a user form, which must be built first and named UserForm1 it is a frame and one form button.
Sub myForm()
ActiveSheet.Select
UserForm1.Show
End Sub
This is the sheet code to pull the form it could be a hot-key or a form button on the worksheet.
Below is the codes required to make the form button on the user form change from red to green with a mouse over and or select and back to red when the focus is lost.
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'On mouse-over, color form back Lt.Blue.
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
'On mouse-over, color Button Green.
If CommandButton1.BackColor <> RGB(122, 255, 0) Then _
CommandButton1.BackColor = RGB(122, 255, 100)
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'On mouse-over = gone, color form back Lt.Blue.
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
'On mouse-over = gone, color Button Red.
If CommandButton1.BackColor <> RGB(255, 0, 0) Then _
CommandButton1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub UserForm_Activate()
'On form open color Back Lt.Blue.
UserForm1.BackColor = RGB(220, 247, 247)
'On form open color Button Bright Red.
If CommandButton1.BackColor <> RGB(255, 0, 0) Then _
CommandButton1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub CommandButton1_Click()
'Deactivate UserForm & color back Lt.Gray.
UserForm1.BackColor = RGB(240, 240, 240)
'Show Msg.
MsgBox Chr(13) & Chr(13) & _
"This could have been any Visual Basic code or Macro!" _
& Chr(13) & Chr(13) & _
"The UserForm ""Button"" has activated this code." _
& Chr(13) & Chr(13) & _
"Any code can be placed here!" _
& Chr(13) & Chr(13) & Chr(13) & Chr(13) & _
" Press ""OK"" when done!" _
& Chr(13)
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
End Sub
Private Sub UserForm_Click()
'If UserForm Background is clicked, close form.
UserForm1.Hide
End Sub
Each code block accounts for a different event. Some action/response may need a code block to initialize another to be defined and another to activate all for one action. JSW
I want to create a form in Excell, I know how to program vb. The thing which i want to know is Excell's coding resembles that of VB? Regards,
Posted by Joe Was on January 23, 2002 6:09 AM
Hayi, Excel uses VBA not VB for the most part.
VBA is Visual Basic for Applications and is VB but has been extended beyond VB to accommodate the the application it is used in (Excel, Access or what-ever). In VBA for Excel, code to work with functions, sheet addressing, formatting, data acquisition and other Excel aspects, unique to Excel have been added. The style is the same but if you use the code from VB to try and pull a userform in Excel it will fail, you must use VBA and use the event handles from Excel's UserForm library to work the options. JSW
Posted by Hayi on January 24, 2002 12:24 PM
Re: Hayi, Excel uses VBA not VB for the most part.
Thanks
Ur comments r valuable for me
VBA is Visual Basic for Applications and is VB but has been extended beyond VB to accommodate the the application it is used in (Excel, Access or what-ever). In VBA for Excel, code to work with functions, sheet addressing, formatting, data acquisition and other Excel aspects, unique to Excel have been added. The style is the same but if you use the code from VB to try and pull a userform in Excel it will fail, you must use VBA and use the event handles from Excel's UserForm library to work the options. JSW