D
d.i.barr
Could anyone help me with this query. I simply want to create a line
that changes colour, which I can do in part. But why when I run the
code, when BLUE or GREEN is entered into Test Sub, it just runs as
RED?
Code:
--------------------
Sub TestShoot()
Call DrawShooting(171#, 115.5, 255.75, 167.25, 2, "BLUE")
End Sub
Sub DrawShooting(StartX As Single, StartY As Single, EndX As Single, EndY As Single, _
Shots As Integer, Optional Color As String)
Dim Shot As Shape
Dim i As Integer
Dim j As Integer
'AddLine(BeginX As Single, BeginY As Single, EndX As Single, EndY As Single) As Shape - Member of Excel.Shapes
If IsMissing(Color) Then
Color = "RED"
ElseIf Color <> "GREEN" Or Color <> "BLUE" Then
Color = "RED"
End If
Select Case Color
Case "RED"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(255, 0 + j, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
Case "GREEN"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 255, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
Case "BLUE"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 0 + j, 255)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
End Select
End Sub
that changes colour, which I can do in part. But why when I run the
code, when BLUE or GREEN is entered into Test Sub, it just runs as
RED?
Code:
--------------------
Sub TestShoot()
Call DrawShooting(171#, 115.5, 255.75, 167.25, 2, "BLUE")
End Sub
Sub DrawShooting(StartX As Single, StartY As Single, EndX As Single, EndY As Single, _
Shots As Integer, Optional Color As String)
Dim Shot As Shape
Dim i As Integer
Dim j As Integer
'AddLine(BeginX As Single, BeginY As Single, EndX As Single, EndY As Single) As Shape - Member of Excel.Shapes
If IsMissing(Color) Then
Color = "RED"
ElseIf Color <> "GREEN" Or Color <> "BLUE" Then
Color = "RED"
End If
Select Case Color
Case "RED"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(255, 0 + j, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
Case "GREEN"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 255, 0 + j)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
Case "BLUE"
For i = 1 To Shots
Set Shot = ActiveSheet.Shapes.AddLine(StartX, StartY, EndX, EndY)
For j = 1 To 255
Shot.Line.ForeColor.RGB = RGB(0 + j, 0 + j, 255)
Application.Wait Now() + 0.0000007
Next
Shot.delete
Next
End Select
End Sub