|
-
Nov 27th, 2000, 07:07 PM
#1
Thread Starter
Lively Member
is there anyway to skip a certin part of code with the If Then And Else Statement. i need to skip the following part of code
Dim f As Form, c As Control
' Get Form Object from Collection of Forms
For Each f In Forms
' Change Backcolor as form to a Random Color
f.BackColor = picBackcolor.BackColor
' Will loop through every kind of control currently on form
For Each c In f.Controls
' Determine is current control is a Label
If TypeOf c Is Label Then
'Change BackColor property to a Random Color
c.ForeColor = picFontcolor.BackColor
End If
Next c
Next f
-
Nov 27th, 2000, 07:16 PM
#2
Lively Member
Not sure exactly what you are after.
-
Nov 27th, 2000, 07:18 PM
#3
Fanatic Member
Under what condition do you need to skip these lines of code???
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Nov 27th, 2000, 11:36 PM
#4
Fanatic Member
you didn't give us a condition at which you want to skip this code...so here is an example:
Code:
If Text1.Text = "Skip" Then
Exit Sub
Else
Dim f As Form, c As Control
' Get Form Object from Collection of Forms
For Each f In Forms
' Change Backcolor as form to a Random Color
f.BackColor = picBackcolor.BackColor
' Will loop through every kind of control currently on form
For Each c In f.Controls
' Determine is current control is a Label
If TypeOf c Is Label Then
'Change BackColor property to a Random Color
c.ForeColor = picFontcolor.BackColor
End If
Next c
Next f
End If
Hope that helps,
D!m
-
Nov 28th, 2000, 05:22 AM
#5
You can also d very naughty things with the infamous Goto statement, which allows you to jump to a label.
Not recommended, but it will work.
(I can't believe I just recommended using Goto )
- gaffa
-
Nov 28th, 2000, 05:46 AM
#6
Hyperactive Member
if you do use goto, you will find 500 vb coders knocking your door to beat then livin' **** out of you.
Gaffa, you lookin' for a slap or what ;-?
td.
(beer)
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 28th, 2000, 06:46 AM
#7
Thread Starter
Lively Member
k
Thank you all, i got it now
-
Nov 28th, 2000, 07:08 AM
#8
Thread Starter
Lively Member
?
ok here is the code for my entire form and when some one clicks the CANCEL button i need the form and label colors to go back to how they were before that form loaded.
Private Sub cmdApply_Click()
If (txtOwner.Text = "") And (txtName.Text = "") Then
frmMain.Caption = "Main"
Else
frmMain.Caption = txtName.Text + "-" + txtOwner.Text
End If
If (picBackcolor.BackColor = &H8000000F) And (picFontcolor.BackColor = &H8000000F) Then
Exit Sub
End If
Load frmAbout
Load frmCreateWrestler
Load frmEditWrestler
Load frmHelp
Load frmMain
Load frmOptions
Load frmWrestlerInfo
Dim f As Form, c As Control
' Get Form Object from Collection of Forms
For Each f In Forms
' Change Backcolor as form to a Random Color
f.BackColor = picBackcolor.BackColor
' Will loop through every kind of control currently on form
For Each c In f.Controls
' Determine is current control is a Label
If TypeOf c Is Label Then
'Change BackColor property to a Random Color
c.ForeColor = picFontcolor.BackColor
'Change BackStyle To Transparent
c.BackStyle = 0
End If
Next c
Next f
End Sub
Private Sub cmdCancel_Click()
Load frmAbout
Load frmCreateWrestler
Load frmEditWrestler
Load frmHelp
Load frmMain
Load frmOptions
Load frmWrestlerInfo
Dim f As Form, c As Control
' Get Form Object from Collection of Forms
For Each f In Forms
' Change Backcolor as form to a Random Color
f.BackColor = &H8000000F
' Will loop through every kind of control currently on form
For Each c In f.Controls
' Determine is current control is a Label
If TypeOf c Is Label Then
'Change BackColor property to a Random Color
c.ForeColor = &H404040
End If
Next c
Next f:
frmMain.Caption = "Main"
Unload Me
End Sub
Private Sub cmdOk_Click()
If (txtOwner.Text = "") And (txtName.Text = "") Then
frmMain.Caption = "Main"
Else
frmMain.Caption = txtName.Text + "-" + txtOwner.Text
End If
If (picBackcolor.BackColor = &H8000000F) And (picFontcolor.BackColor = &H8000000F) Then
Exit Sub
End If
Load frmAbout
Load frmCreateWrestler
Load frmEditWrestler
Load frmHelp
Load frmMain
Load frmOptions
Load frmWrestlerInfo
Dim f As Form, c As Control
' Get Form Object from Collection of Forms
For Each f In Forms
' Change Backcolor as form to a Random Color
f.BackColor = picBackcolor.BackColor
' Will loop through every kind of control currently on form
For Each c In f.Controls
' Determine is current control is a Label
If TypeOf c Is Label Then
'Change BackColor property to a Random Color
c.ForeColor = picFontcolor.BackColor
'Change BackStyle To Transparent
c.BackStyle = 0
End If
Next c
Next f
Unload Me
End Sub
Private Sub Form_Load()
frmMain.Caption = "":
Me.BackColor = picBackcolor.BackColor
End Sub
Private Sub picBackcolor_Click()
Dim CustomColours() As Byte
'Define array for custom colours.
ReDim CustomColours(0 To 15) As Byte
'Resize the array to hold the elements
Dim tChooseColour As CHOOSECOLOR
'Declare a user-defined variable for the ChooseColour
'type structure.
With tChooseColour
.hwndOwner = Me.hWnd
'Set the handle for the owner of the window.
.lpCustColors = StrConv(CustomColours, vbUnicode)
'Pass the custom colours array after converting
'it to Unicode using the StrConv function.
.flags = 0&
'For this sample, we do not need to use this.
.lStructSize = Len(tChooseColour)
'Set the size of the type structure
End With
If ShowColour(tChooseColour) = 0 Then Exit Sub
'Call the API function and display the ChooseColour
'Common Dialog box, and if the users clicks on cancel
'then the function will return 0.
picBackcolor.BackColor = tChooseColour.rgbResult
'Set the back colour of the form to the colour
'that the user selected.
End Sub
Private Sub picFontcolor_Click()
Dim CustomColours() As Byte
'Define array for custom colours.
ReDim CustomColours(0 To 15) As Byte
'Resize the array to hold the elements
Dim tChooseColour As CHOOSECOLOR
'Declare a user-defined variable for the ChooseColour
'type structure.
With tChooseColour
.hwndOwner = Me.hWnd
'Set the handle for the owner of the window.
.lpCustColors = StrConv(CustomColours, vbUnicode)
'Pass the custom colours array after converting
'it to Unicode using the StrConv function.
.flags = 0&
'For this sample, we do not need to use this.
.lStructSize = Len(tChooseColour)
'Set the size of the type structure
End With
If ShowColour(tChooseColour) = 0 Then Exit Sub
'Call the API function and display the ChooseColour
'Common Dialog box, and if the users clicks on cancel
'then the function will return 0.
picFontcolor.BackColor = tChooseColour.rgbResult
'Set the back colour of the form to the colour
'that the user selected.
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|