Beginner in trouble

how do i change the "intName = intName + IntName" statement to a Count statement. What am I doing wrong?

THIS WORKS

Const conMsg As String = "The total number sold is "
Dim strItem As String, intNumber As Integer
Open "c:co206Tut06lc5.dat" For Input As #1 'open the sequential file"
Do While Not EOF(1)
Input #1, strItem, intNumber 'read a file'
intNumber = intNumber + intNumber + intNumber
lblTotal.Caption = conMsg & Val(intNumber)
Loop
Close #1
End Sub

___________________________________________________________
THIS DOESNT WORK

IntCount as integer
for intCount = 0 to 3
intCount = intCount + 1
lblTotal(intCount).caption = Val(intNumber)
next intCount
_____________________________________________________________



Comments

  • : how do i change the "intName = intName + IntName" statement to a Count statement. What am I doing wrong?
    :
    : THIS WORKS
    :
    : Const conMsg As String = "The total number sold is "
    : Dim strItem As String, intNumber As Integer
    : Open "c:co206Tut06lc5.dat" For Input As #1 'open the sequential file"
    : Do While Not EOF(1)
    : Input #1, strItem, intNumber 'read a file'
    : intNumber = intNumber + intNumber + intNumber
    : lblTotal.Caption = conMsg & Val(intNumber)
    : Loop
    : Close #1
    : End Sub
    :
    : ___________________________________________________________
    : THIS DOESNT WORK
    :
    : IntCount as integer
    : for intCount = 0 to 3
    : intCount = intCount + 1
    : lblTotal(intCount).caption = Val(intNumber)
    : next intCount
    : _____________________________________________________________
    :
    :
    Well..
    Do like this
    1. Get the numbers of labels you have !
    2. Write this code

    Dim intCount As Integer
    For intCount = 0 To 3
    intCount = intCount + 1
    lblTotal(intCount).Caption = Val(intCount)
    Next intCount

    in my example I put 3 lable
    if you have 2 the change
    For intCount = 0 To 2


  • you dont increment the value in the For statement. For already does that.

    for intCount = 0 to 3
    intCount = intCount + 1
    lblTotal(intCount).caption = Val(intNumber)
    next intCount

    Change it to something like

    for a = 0 to 3
    intCount = a + 1
    lblTotal(intCount).caption = Val(intNumber)
    next a




    : how do i change the "intName = intName + IntName" statement to a Count statement. What am I doing wrong?
    :
    : THIS WORKS
    :
    : Const conMsg As String = "The total number sold is "
    : Dim strItem As String, intNumber As Integer
    : Open "c:co206Tut06lc5.dat" For Input As #1 'open the sequential file"
    : Do While Not EOF(1)
    : Input #1, strItem, intNumber 'read a file'
    : intNumber = intNumber + intNumber + intNumber
    : lblTotal.Caption = conMsg & Val(intNumber)
    : Loop
    : Close #1
    : End Sub
    :
    : ___________________________________________________________
    : THIS DOESNT WORK
    :
    : IntCount as integer
    : for intCount = 0 to 3
    : intCount = intCount + 1
    : lblTotal(intCount).caption = Val(intNumber)
    : next intCount
    : _____________________________________________________________
    :
    :



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories