visual basic code help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mubs
    New Member
    • Mar 2007
    • 77

    visual basic code help

    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..

    [code=vb]

    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.CellBackCo lor = colourshow(sect ors(i))
    Else
    MSf1.CellBackCo lor = 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(whichse ctor) = 0

    Wend
    Call redisp
    End If
    End Sub

    Private Sub Command3_Click( )
    If (Not (List1.ListCoun t = 0)) Then
    List1.RemoveIte m (List1.ListCoun t - 1)

    End If
    If sectors(i) = True Then
    MSf1.CellBackCo lor = RGB(0, 0, 0)
    End If
    End Sub

    Private Sub Command4_Click( )
    Call redisp
    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.FillColo r = RGB(i * 40, j * 40, k * 40)
    colourshow(num) = Shape1.FillColo r
    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.Enable d = True
    Command1.Enable d = False
    Command3.Enable d = True
    Else
    Command1.Enable d = True
    Command2.Enable d = False
    Command3.Enable d = False
    End If
    End If
    End Sub

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

    End Sub[/code]
    Last edited by debasisdas; Dec 6 '07, 06:37 AM. Reason: formatted using code tags
Working...