Results 1 to 6 of 6

Thread: How do I set tab movement in an array????????

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    47

    How do I set tab movement in a CONTROL array?????

    I want my tab to flow from txtGrade(0) to txtHours(0) to
    txtGrade(1) to txtHours(1)...etc

    The way I have tried obviously doesn't work - HELP! assignment due tomorrow!

    Option Explicit

    Private Sub cmdCalculate_Click()
    picDisplay.Cls
    Call ttlPts
    picDisplay.Print "Have a merry vacation."
    End Sub

    Private Sub cmdExit_Click()
    End
    End Sub

    Private Sub Form_Load()
    Dim prompt As String
    Dim title As String
    Dim i As Integer
    Dim Index As Integer
    Dim Amt As Integer
    picDisplay.AutoRedraw = True
    title = "Number of Courses to Average"
    prompt = "Enter number of courses to average the grade point"
    Amt = InputBox(prompt, title)
    i = 0
    lblGrade(i).Caption = "Course # " & i + 1 & " Grade"
    lblHours(i).Caption = "Credit Hours"
    For i = 1 To Amt - 1
    Load lblGrade(i)
    Load txtGrade(i)
    Load lblHours(i)
    Load txtHours(i)
    lblGrade(i).Top = lblGrade(i - 1).Top + lblGrade(0).Height
    txtGrade(i).Top = txtGrade(i - 1).Top + txtGrade(0).Height
    lblHours(i).Top = lblHours(i - 1).Top + lblHours(0).Height
    txtHours(i).Top = txtHours(i - 1).Top + txtHours(0).Height
    lblGrade(i).Visible = True
    txtGrade(i).Visible = True
    lblHours(i).Visible = True
    txtHours(i).Visible = True
    lblGrade(i).Caption = "Course #" & i + 1 & " Grade"
    lblHours(i).Caption = "Credit Hours"
    Next i
    Call txtGrade_GotFocus(Index)
    End Sub

    Public Function GPA() As Single
    Dim points As Single
    Dim grade As String
    Dim TotalPts As Integer
    Dim counter As Integer
    Dim i As Integer
    counter = 0
    points = 0
    TotalPts = 0
    For i = 0 To txtGrade.UBound
    grade = UCase(txtGrade(i).Text)
    Select Case grade
    Case "A", "A+"
    points = 4
    Case "A-"
    points = 3.8
    Case "B+"
    points = 3.3
    Case "B"
    points = 3
    Case "B-"
    points = 2.8
    Case "C+"
    points = 2.3
    Case "C"
    points = 2
    Case "C-"
    points = 1.8
    Case "D+", "D", "D-"
    points = 1
    Case "F"
    points = 0
    Case Else
    points = 0
    End Select

    TotalPts = points + TotalPts
    Next i
    GPA = TotalPts / i
    End Function

    Private Sub ttlPts()
    Dim GrdPA As Single
    GrdPA = GPA()
    picDisplay.Print "Your Grade Point Average is "; GrdPA
    If GrdPA >= 3 Then
    picDisplay.Print "You have made the honor roll."
    Else
    picDisplay.Print " Congratulations on completing the semester."
    End If
    End Sub


    Private Sub txtGrade_GotFocus(Index As Integer)
    Dim i As Integer
    i = Index
    Select Case Index
    Case 0
    txtGrade(i).TabIndex = 0
    txtHours(i).TabIndex = 1
    Case 1
    txtGrade(i).TabIndex = 2
    txtHours(i).TabIndex = 3
    Case 2
    txtGrade(i).TabIndex = 4
    txtHours(i).TabIndex = 5
    Case 3
    txtGrade(i).TabIndex = 6
    txtHours(i).TabIndex = 7
    Case 4
    txtGrade(i).TabIndex = 8
    txtHours(i).TabIndex = 9
    Case 5
    txtGrade(i).TabIndex = 10
    txtHours(i).TabIndex = 11
    Case 6
    txtGrade(i).TabIndex = 12
    txtHours(i).TabIndex = 13
    End Select
    End Sub


  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658

    Question Tab Index ???

    Are you talking about which order the controls get the focus when tabbing.

    If so all you have to do is set the TabIndex property of each control accordingly. This is done at design time usually.

    e.g.
    Code:
    txtGrade(0).TabIndex = 1
    txtHours(0).TabIndex = 2
    txtGrade(1).TabIndex = 3
    txtHours(1).TabIndex = 4
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    47
    This will not work if you are setting up the array at run time.
    The program will error when it runs into the array not used.

    Any other suggestions?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    How to irretate trough all controls
    For each n in controlname
    'Blahblah
    next n
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2000
    Posts
    47
    Excuse me?

    I guess I don't understand what you are saying.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Talking

    Ok, I'm sure not the best to explain things. For each is like for next, but instead n is a numeric, n is the a item in your controlarray
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width