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

visual basic code help

P: 77
could some one help with the following:

i need to delete the sectors created in list and the flex grid to show this

and

need help with the "modify"...when modifying the sizes bigger than what was entered in text 2.. to be then shown in the flex grid..

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim colourshow(125) As Double, sectors(1023) As Integer
  3.  
  4. Private Sub Command1_Click()
  5. Rem create, look for contiguous sectors of right length
  6. i = 0
  7. N = Val(Text2.Text)
  8. inloopb = True
  9. While inloopb
  10.     If sectors(i) = 0 Then
  11.         Rem one blank found, now for the next N
  12.         inloop = True
  13.         j = 1
  14.         found = False
  15.         While inloop
  16.             If sectors(i + j) > 0 Then
  17.                 inloop = False
  18.             Else
  19.                 If j = N Then
  20.                     found = True
  21.                     inloop = False
  22.                 Else
  23.                     If j < 1023 Then
  24.                         j = j + 1
  25.                     Else
  26.                         MsgBox "Memory full", vbCritical
  27.                         inloop = False
  28.                     End If
  29.                 End If
  30.             End If
  31.         Wend
  32.         If found Then
  33.             List1.AddItem Text1.Text
  34.             Rem i points to first
  35.             For j = 0 To N - 1
  36.                 sectors(i + j) = Val(Text1.Text)
  37.             Next j
  38.             Call redisp
  39.             inloopb = False
  40.         Else
  41.             i = i + 1
  42.         End If
  43.  
  44.         If i = 1023 Then
  45.             MsgBox "Memory full", vbCritical
  46.             inloopb = False
  47.         Else
  48.             i = i + 1
  49.         End If
  50.     Else
  51.         i = i + 1
  52.     End If
  53. Wend
  54. End Sub
  55. Private Sub redisp()
  56.  
  57. For i = 0 To 1023
  58.  
  59.     myrow = Int(i / 16)
  60.     mycol = i - myrow * 16
  61.     MSf1.Row = myrow
  62.     MSf1.Col = mycol + 1
  63.     If sectors(i) > 0 Then
  64.         MSf1.CellBackColor = colourshow(sectors(i))
  65.     Else
  66.         MSf1.CellBackColor = RGB(0, 0, 0)
  67.  
  68.     End If
  69. Next i
  70. End Sub
  71.  
  72. Private Sub Command2_Click()
  73. Rem first check how big file is now
  74. runtot = 0
  75. List2.Clear
  76. For i = 0 To 1023
  77.     If sectors(i) = Val(Text1) Then
  78.         List2.AddItem Str(i)
  79.         runtot = runtot + 1
  80.     End If
  81. Next i
  82. If runtot > Val(Text2.Text) Then
  83.     Rem file is smaller
  84.     Rem use list box to save sectors back to zero
  85.     List2.ListIndex = Val(Text2.Text) - 1
  86.     While List2.ListIndex < List2.ListCount - 1
  87.         List2.ListIndex = List2.ListIndex + 1
  88.         whichsector = Val(List2.Text)
  89.         sectors(whichsector) = 0
  90.  
  91.     Wend
  92.     Call redisp
  93. End If
  94. End Sub
  95.  
  96. Private Sub Command3_Click()
  97.      If (Not (List1.ListCount = 0)) Then
  98.          List1.RemoveItem (List1.ListCount - 1)
  99.  
  100.      End If
  101.  If sectors(i) = True Then
  102.         MSf1.CellBackColor = RGB(0, 0, 0)
  103.     End If
  104. End Sub
  105.  
  106. Private Sub Command4_Click()
  107. Call redisp
  108. End Sub
  109.  
  110. Private Sub Command5_Click()
  111. Timer1.Interval = 10
  112. End Sub
  113.  
  114.  
  115. Private Sub Form_Load()
  116. MSf1.Rows = 64
  117. MSf1.Cols = 17
  118. MSf1.ColWidth(0) = 400
  119. For i = 1 To 16
  120.     MSf1.ColWidth(i) = 250
  121. Next i
  122. num = 0
  123. Rem now lets have 125 colours in global array
  124. For i = 1 To 5
  125.     For j = 1 To 5
  126.         For k = 1 To 5
  127.             Shape1.FillColor = RGB(i * 40, j * 40, k * 40)
  128.             colourshow(num) = Shape1.FillColor
  129.             num = num + 1
  130.         Next k
  131.     Next j
  132. Next i
  133.  
  134. End Sub
  135.  
  136. Private Sub Text1_Change()
  137. Rem as file number is entered, check if it is in list
  138. If Val(Text1.Text) > 0 Then
  139.     hit = False
  140.     For i = 0 To List1.ListCount - 1
  141.         List1.ListIndex = i
  142.         If Val(Text1) = Val(List1.Text) Then
  143.  
  144.             hit = True
  145.         End If
  146.     Next i
  147.     If hit Then
  148.         Command2.Enabled = True
  149.         Command1.Enabled = False
  150.         Command3.Enabled = True
  151.     Else
  152.         Command1.Enabled = True
  153.         Command2.Enabled = False
  154.         Command3.Enabled = False
  155.     End If
  156. End If
  157. End Sub
  158.  
  159. Private Sub Timer1_Timer()
  160. Label4.Left = Label4.Left + 20
  161. Shape2.Left = Shape2.Left + 20
  162. If Shape2.Left >= Label9.Left Then
  163.     Timer1.Enabled = False
  164. End If
  165.  
  166. End Sub
Dec 4 '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.