Results 1 to 3 of 3

Thread: chat

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    216

    chat

    (ii have vb.net standard '02)

    hey, i was wondering how i could have a chat box on my game that i am making. I already have to down but i th ink there is an easier and more efficient way of doing it.

    its bassically like this (so far):
    Code:
    chatwindow.text = chatwindow.text & vbcrlf & (username) & ":" & chattext.text
    thats the code under the submit button.
    the problem is that when i run it, the window doesnt automattically scroll down all the way when i submit it. so each time i send a message out to chat window it just shows the top lines and i would have to scroll down to the bottom to read the message. i know there must be an easier way of doing this and i was wonderingn what that could be..

    also, i know this is going to be easy but i just have a brain block- i want it so that the user only has to press enter to submit the text to the main window but i forget what that line of code is ( is it somehting like (Asc(e.char)) = 13 ??)

    thanks in advance,
    James

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    To force the textbox to scroll, after you add a line of chat, use this handy snippet:
    Code:
    txtChat.SelectionStart = txtChat.Text.Length;
    txtChat.SelectionLength = 0;
    To use Enter to send text, you'll need to check e.KeyChar in the textbox_keyPressed event:.
    (Psuedo C# code)
    Code:
    if (e.KeyChar == '\r')
    {
       e.Handled = true; // kill beeping noise
       // send text
       txtChat.Text = ""; // clear textbox
    }
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    216
    i couldnt get the selction start/lenght code snippet to work. it would just do the same thing. i was wondering if it would have to do with the fact that im re-typing whats in the chatwindow box? and not just adding to it?

    i didnt really try your e.keychar one but i wanted to tell u that im programming in vb (i can do alittle vc++ but not much)

    thanks

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