|
-
May 15th, 2008, 09:03 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Some help with If statement logic
I know this should be really simple but I'm having trouble figuring out the logic.
I have a form that can create scheduled tasks. To create the task the user must complete 3 different sections
Days of Week
Days of Month
Task Command Line
For the Days of Week and Days of Month there are various checkboxes they can check and I assign an Integer to the Tag property of each one.
The Task Command line is a simple textbox
Now, when they click the CREATE TASK button I want to check that they have selected at least one checkbox in the Days of Week and Days of Month sections as well as entered a command line
I was doing this before
Code:
For Each Ctrl As Control In Me.GroupBox_DaysofMonth.Controls
If TypeOf Ctrl Is CheckBox AndAlso DirectCast(Ctrl, CheckBox).Checked Then
DaysOfMonthValue = DaysOfMonthValue + CInt(DirectCast(Ctrl, CheckBox).Tag.ToString)
End If
Next
For Each Ctrl As Control In Me.GroupBox_DaysofMonth.Controls
If TypeOf Ctrl Is CheckBox AndAlso DirectCast(Ctrl, CheckBox).Checked Then
DaysOfWeekValue = DaysOfWeekValue + CInt(DirectCast(Ctrl, CheckBox).Tag.ToString)
End If
Next
If DaysOfMonthValue + DaysOfWeekValue = 0 AndAlso Me.CommandToRun.Text.Equals(String.Empty) Then
But I just realised that this allows them to select any number of checkboxes but leave the command line blank.
Any advice appreciated
ManagePC - the all-in-one PC management and inventory tool
-
May 15th, 2008, 09:13 AM
#2
Re: [2005] Some help with If statement logic
Shouldn't that last line be OrElse rather than AndAlso? Surely you want to know where either one or the other is True.
-
May 15th, 2008, 09:26 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Some help with If statement logic
I tried that. But if the user selects checkboxes in the Days Of Week section , none in the Days Of Month section AND enters a command line it still says throws the error message
ManagePC - the all-in-one PC management and inventory tool
-
May 15th, 2008, 09:38 AM
#4
Fanatic Member
Re: [2005] Some help with If statement logic
Well I am assuming that this is all run inside of a button_click event, so why not have a check.
Are the appropriate CheckBoxes ticked? If yes then carry on.
Is the Command Line Blank? If yes Carry on.
Etc
-
May 15th, 2008, 09:50 AM
#5
Thread Starter
Fanatic Member
Re: [2005] Some help with If statement logic
Well, I have to add up the values of the Tag properties anyway because it is used as a value by the WMI namespace Win32_ScheduledJob so it made sense to just check whether the combined value was 0 or not
ManagePC - the all-in-one PC management and inventory tool
-
May 15th, 2008, 09:52 AM
#6
Fanatic Member
Re: [2005] Some help with If statement logic
Well it does seem like a good idea to me. but if it is not working, then you will have to change your idea. Unless there is something else I have missed.
-
May 15th, 2008, 03:29 PM
#7
Thread Starter
Fanatic Member
Re: [2005] Some help with If statement logic
Ah well, I had to change it in the end as I realised I was COMPLETELY misunderstaning how WMI creates Scheduled Tasks
ManagePC - the all-in-one PC management and inventory tool
-
May 16th, 2008, 03:41 AM
#8
Fanatic Member
Re: [2005] Some help with If statement logic
So it is all sorted?
Mind Marking this thread resolved then please.
Glad you have it sorted
-
May 16th, 2008, 04:19 AM
#9
Thread Starter
Fanatic Member
Re: [2005] Some help with If statement logic
Well, not yet no as I'm now using a 3rd party class that acts as a wrapper for the WMI Win32_ScheduledJob namespace. It's MUCH easier
ManagePC - the all-in-one PC management and inventory tool
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
|