lexluther88
11-29-2006, 06:50 PM
I'm making this drawing program called BOGO in excel, VBA. It's for a class. I simply can't figure out how to start it. The website can be found as follows:
http://www.cs.uiuc.edu/class/fa06/cs105/
Then on the left side click on "Machine problems (Mp's)
Then click "Mp6" in the middle of the screen.
The actual given Excel file can be downloaded to see what's been given and such.
I'm stuck on the first part of the assignment, being the validate fuction.
"You should implement Validate by writing code between the Function Validate and End Function lines. The Validate function is used to check to see if the current instruction is a valid BOGO instruction. Using the function's parameter intCurRow, which holds the row of the instruction we're attempting to validate, check each of the three parts of the instruction (Direction, Distance, Color) to see that they conform to the BOGO specification described in the Introduction (Table 1). If any part of the instruction does not conform to the table, change the background color of all three cells to red and return False. Otherwise, return True.
The syntax for changing the background color of a cell to red is
Cells(intMyRow, intMyCol).Interior.Color = vbRed
If anyone could help me with the the code I'd very much appreciate it..what I'm trying now looks wrong in many ways, but it's:
Public Function validate(intCurRow As Integer) As Boolean
Dim intMyRow As Boolean
Dim intMyCol As Boolean
If Range("A4:C4").Value = "U" Or "D" Or "R" Or "L" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If
If Range("B4:B100").intCurRow.Value = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "9" Or "10" Or "11" Or "12" Or "13" Or "14" Or "15" Or "16" Or "17" Or "18" Or "19" Or "20" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If
If Range("C4:C100").intCurRow.Value = "Black" Or "Red" Or "Green" Or "Yellow" Or "Blue" Or "Magenta" Or "Cyan" Or "White" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If
http://www.cs.uiuc.edu/class/fa06/cs105/
Then on the left side click on "Machine problems (Mp's)
Then click "Mp6" in the middle of the screen.
The actual given Excel file can be downloaded to see what's been given and such.
I'm stuck on the first part of the assignment, being the validate fuction.
"You should implement Validate by writing code between the Function Validate and End Function lines. The Validate function is used to check to see if the current instruction is a valid BOGO instruction. Using the function's parameter intCurRow, which holds the row of the instruction we're attempting to validate, check each of the three parts of the instruction (Direction, Distance, Color) to see that they conform to the BOGO specification described in the Introduction (Table 1). If any part of the instruction does not conform to the table, change the background color of all three cells to red and return False. Otherwise, return True.
The syntax for changing the background color of a cell to red is
Cells(intMyRow, intMyCol).Interior.Color = vbRed
If anyone could help me with the the code I'd very much appreciate it..what I'm trying now looks wrong in many ways, but it's:
Public Function validate(intCurRow As Integer) As Boolean
Dim intMyRow As Boolean
Dim intMyCol As Boolean
If Range("A4:C4").Value = "U" Or "D" Or "R" Or "L" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If
If Range("B4:B100").intCurRow.Value = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "9" Or "10" Or "11" Or "12" Or "13" Or "14" Or "15" Or "16" Or "17" Or "18" Or "19" Or "20" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If
If Range("C4:C100").intCurRow.Value = "Black" Or "Red" Or "Green" Or "Yellow" Or "Blue" Or "Magenta" Or "Cyan" Or "White" Then
validate = True
Else
validate = False And Cells(intMyRow, intMyCol).Interior.Color = vbRed
End If