By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

add colour in cells

P: 77
can some1 help with the this problem....

I need to a button which would modify the sizes bigger in text box 2 than what was entered first in text box 2.. to be then shown with colour specified in the flex grid as changed...

code so far...

Dim colourshow(125) As Double, sectors(1023) As Integer


Private Sub Command1_Click()
Rem create, look for contiguous sectors of right length
i = 0
N = Val(Text2.Text)
inloopb = True
While inloopb
If sectors(i) = 0 Then
Rem one blank found, now for the next N
inloop = True
j = 1
found = False
While inloop
If sectors(i + j) > 0 Then
inloop = False
Else
If j = N Then
found = True
inloop = False
Else
If j < 1023 Then
j = j + 1
Else
MsgBox "Memory full", vbCritical
inloop = False
End If
End If
End If
Wend
If found Then
List1.AddItem Text1.Text
Rem i points to first
For j = 0 To N - 1
sectors(i + j) = Val(Text1.Text)
Next j
Call redisp
inloopb = False
Else
i = i + 1
End If

If i = 1023 Then
MsgBox "Memory full", vbCritical
inloopb = False
Else
i = i + 1
End If
Else
i = i + 1
End If
Wend
End Sub
Private Sub redisp()

For i = 0 To 1023

myrow = Int(i / 16)
mycol = i - myrow * 16
MSf1.Row = myrow
MSf1.Col = mycol + 1
If sectors(i) > 0 Then
MSf1.CellBackColor = colourshow(sectors(i))
Else
MSf1.CellBackColor = RGB(0, 0, 0)

End If
Next i
End Sub

Private Sub Command2_Click()
Rem first check how big file is now
runtot = 0
List2.Clear
For i = 0 To 1023
If sectors(i) = Val(Text1) Then
List2.AddItem Str(i)
runtot = runtot + 1
End If
Next i
If runtot > Val(Text2.Text) Then
Rem file is smaller
Rem use list box to save sectors back to zero
List2.ListIndex = Val(Text2.Text) - 1
While List2.ListIndex < List2.ListCount - 1
List2.ListIndex = List2.ListIndex + 1
whichsector = Val(List2.Text)
sectors(whichsector) = 0

Wend
Call redisp
End If
End Sub

Private Sub Command3_Click()
For i = 0 To 1023
If sectors(i) = Val(Text1.Text) Then
sectors(i) = 0
End If
Next

While List2.ListIndex < List2.ListCount - 1
List2.ListIndex = List2.ListIndex + 1
whichsector = Val(List2.Text)
sectors(whichsector) = 0

Wend
Call redisp
List1.RemoveItem List1.ListIndex
End Sub

Private Sub Command4_Click()

End Sub


Private Sub Command5_Click()
Timer1.Interval = 10
End Sub


Private Sub Form_Load()
MSf1.Rows = 64
MSf1.Cols = 17
MSf1.ColWidth(0) = 400
For i = 1 To 16
MSf1.ColWidth(i) = 250
Next i
num = 0
Rem now lets have 125 colours in global array
For i = 1 To 5
For j = 1 To 5
For k = 1 To 5
Shape1.FillColor = RGB(i * 40, j * 40, k * 40)
colourshow(num) = Shape1.FillColor
num = num + 1
Next k
Next j
Next i

End Sub

Private Sub Text1_Change()
Rem as file number is entered, check if it is in list
If Val(Text1.Text) > 0 Then
hit = False
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
If Val(Text1) = Val(List1.Text) Then

hit = True
End If
Next i
If hit Then
Command2.Enabled = True
Command1.Enabled = False
Command3.Enabled = True
Else
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
End If
End If
End Sub

Private Sub Timer1_Timer()
Shape2.Left = Shape2.Left + 13
If Shape2.Left >= Label9.Left Then
Timer1.Enabled = False
End If

End Sub
Dec 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.