Results 1 to 2 of 2

Thread: Loop without do?

  1. #1
    emcee
    Guest

    Question Loop without do?

    When I try to run this code vb keeps highlighting the line commented with "this on" and saying it is a loop without a do, yet there is clearly a do, what's the problem?.


    Private Sub Command1_Click()
    Dim fred As Long
    Dim bob As Long
    Dim dan As Long
    Dim jack As Long
    Dim abe As Long
    Dim larry As String
    abe = 0
    bob = 0
    Do
    dan = Len(Text4.Text) - bob
    jack = Text2.Text ^ bob
    fred = Mid(Text4.Text, dan, 1) * jack
    abe = abe + fred
    bob = bob + 1
    Loop Until bob = Len(Text4.Text)
    fred = abe
    bob = 0
    dan = 0
    jack = 0
    Do
    al = fred
    Do
    dan = (Text1.Text - 1) * (Text1.Text ^ bob)
    If fred > dan Then
    larry = 0 + larry
    Else
    If fred < dan Then
    jack = Round((dan / fred), 0)
    larry = jack + larry
    fred = dan Mod fred
    End If
    bob = bob + 1
    Loop Until fred <> al 'This one
    bob = 0
    Loop Until fred = 0
    End Sub

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274

    Re: Loop without do?

    Originally posted by emcee
    VB Code:
    1. If fred > dan Then
    2.                 larry = 0 + larry
    3.             Else
    4.                 If fred < dan Then
    5.                     jack = Round((dan / fred), 0)
    6.                     larry = jack + larry
    7.                     fred = dan Mod fred
    8.             End If
    Your problem is here. U have an unfinished IF THEN statement. Either u could add an End If at the end of the quoted lines or change the ELSE to an ELSEIF
    Regards
    Stuart

    PS I know the error msg is odd but it is nothing to do with loops just that VB couldnt understand it

    PPS ALSO, Larry is declared as a String which is wrong
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

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