vb.net - call sub to change USERname color -


i want change username color inside ritchtextbox, using code below call sub text in red?

update

sub addmessage(txtusername string, txtsend string)     box.selectioncolor = color.red     box.appendtext(vbcrlf & txtusername & "$ ")     box.selectioncolor = color.black     box.appendtext(txtsend) end sub   private sub button1_click(byval sender system.object, byval e system.eventargs) handles cmdsend.click      ' shell("net send " & txtcomputer.text & " " & txtmessage.text)       try         if txtpcipadd.text = "" or txtusername.text = "" or txtsend.text = ""             msgbox("wright message!", "msgbox")         else             client = new tcpclient(txtpcipadd.text, 44444)             dim writer new streamwriter(client.getstream())              txttempmsg.text = (txtsend.text)             writer.write(txtusername.text + " @ " + txtsend.text)             addmessage(txtusername.text, txttempmsg.text + vbcrlf)             'txtmsg.text="you:" + txtmessage.text)             writer.flush()             txtsend.text = ""         end if     catch ex exception         msgbox(ex.message)     end try end sub 

when have problem trying work in program. easier create test example can use figure out happening without dealing lot of other variables in larger program. in case created vb winforms app, added richtextbox, 2 textbox's , button. doing able show function working.

public class form1     sub addmessage(txtusername string, txtsend string)         box.selectioncolor = color.red         box.appendtext(vbcrlf & txtusername & " :") 'note added colon         box.selectioncolor = color.black         box.appendtext(txtsend)  'note changed variable name parameter name     end sub      private sub button1_click(sender object, e eventargs) handles button1.click         addmessage(txtusername.text, txttempmsg.text)     end sub  end class 

example:

enter image description here


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -