473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

visual basic code help

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
0 925

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

Similar topics

2
by: AK | last post by:
I don't want any part of the previous discussion on Visual Basic versus Visual Basic.Net. My query is about using Visual Basic for Applications; and whether it is better to use Visual Basic 6 or...
33
by: John Timbers | last post by:
I'd like to purchase Visual C# .Net for learning purposes only since it's a lot cheaper than Visual Studio (note that I'm a very experienced C++ developer). Can someone simply clarify the basic...
5
by: K. Shier | last post by:
when attempting to edit code in a class file, i see the bug "Visual Basic ..NET compiler is unable to recover from the following error: System Error &Hc0000005&(Visual Basic internal compiler...
5
by: Microsoft | last post by:
Hi, I have Visual Basic .net 2003 (Standard Edition) & SQL Server 2000 Developer Edition. When trying to create a connection in the server explorer from the .net IDE I get a number of problems;...
2
by: elnahrawi | last post by:
Download ebook http://books-download.com/?Book=1487-Visual+Basic+2005+Jumpstart Okay, all you VB6 developers--time's up. As of March 2005, Microsoft no longer supports this version of Visual...
10
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
1
by: FlyingBuckner | last post by:
All right be kind, this is my first question on a forum. I need help on selecting the right software to purchase. I have a database set up using Access, 6 users. It is split into Tables and...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
6
by: Vince | last post by:
Hello all, I am using Visual Basic to open a saved query and then save information in the query to an array for later use. The problem is that the same query shows different results when opened...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.