Results 1 to 10 of 10

Thread: What is wrong with this?

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    This is my code to cause my chat window to scroll down one line to be ready for the next SendData.

    It is supposed to resemble your standard run of the mill chat window, but I continue to fail in successful implementing an AUTO SCROLLING feature.

    I would sure appreciate it if you could help me out...

    Here is the error I am getting:
    "Runtime error #28, Out of stack space"

    When I hit Debug I am brought to this Sub:

    Code:
    Private Sub Chat_Change()
        Chat.Text = Chat.Text & vbNewLine
        
        'See if auto-scroll is desired
        If chkScroll.Value = 1 Then
            'Start the Auto Scroll
            Chat.SelStart = Len(Chat.Text)
        End If
    End Sub
    The highlighted offending line is:
    Chat.Text = Chat.Text & vbNewLine

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Out of stack space means, that there are two much functions/subs called at the same time.

    This line:
    Code:
    Chat.SelStart = Len(Chat.Text)
    Will raise another Chat_Change event. So, it results in endless-looping.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guest
    Declare a boolean var, wrap the entire code in the sub in an if statement that only enters the if when the boolean var is true. In the first line of the if statement, set the boolean to True, and set it to false at the end of the code inside the if. That way, when the change event is called, it only executes your code if it is not already changing.

    I'd write some code, but I'm in a rush. Sorry

    - gaffa

  4. #4

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Thanks for the reply...

    Thanks guys, much appreciated...

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  5. #5

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Gaffa

    Gaffa is this what you mean....if so, it is failing to auto scroll.

    Code:
    Private Sub Chat_Change()
    Dim TextChange As Boolean
        
        If TextChange = True Then
            Chat.Text = Chat.Text & vbNewLine
            'Auto Scroll
            Chat.SelStart = Len(Chat.Text)
            TextChange = False
        End If
    End Sub
    This auto scrolling and making the text box automatically move down one line is very nerve racking, (That and I'm on the tired side):-)

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  6. #6

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    Any takers?
    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  7. #7
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Just remove the line: Chat.Text = Chat.Text & vbNewLine ...

    The rest of the code will allow for the autoscroll like a dos window/telnet window/mirc, etc. I've done this before and it works. Basically, you want it so the text scrolls up like you're constantly at the last line (not a blank line, unless someone sends an enter)? Then the code that oetje gave you will work perfectly.
    -Excalibur

  8. #8

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    Perfect, I appreciate the tip.

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  9. #9
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    I predict a problem with your code (I might be wrong).

    The boolean should be Static...

    Code:
    Private Sub Chat_Change()
        Static TextChange as Boolean
        If TextChange = True Then
            Chat.Text = Chat.Text & vbNewLine
            'Auto Scroll
            Chat.SelStart = Len(Chat.Text)
            TextChange = False
        End If
    End Sub
    Or Global...

    Code:
    Option Explicit
    Private TextChange as Boolean
    Private Sub Chat_Change()
        If TextChange = True Then
            Chat.Text = Chat.Text & vbNewLine
            'Auto Scroll
            Chat.SelStart = Len(Chat.Text)
            TextChange = False
        End If
    End Sub
    ExcalibursZone is also right. However, if you take the line
    Code:
    Chat.Text = Chat.Text & vbNewLine
    out, you will have to add a line break before adding the next person's chat text.

    r0ach™
    Don't forget to rate the post

  10. #10

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    And naturally, I want to have the code force a line break.
    I appreciate your reply.
    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.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