如何使用VB@newlint

来源:百度知道 编辑:UC知道 时间:2024/07/07 03:44:52
我正在编写一个聊天工具,但是要解决VB编写中的聊天输入 ,当安一次又一次地发送 一行一行地显示到textbox,我听人说可以用VBVB@newlint,但我不会怎用,我发我的代码,看怎用Private Sub Command1_Click()
Dim a, b, c
a = Label1.Caption
b = Text2.Text
c = DTPicker1
Text1.Text = "时间" & c & "(" & a & ")" & "内容:" & b
End Sub
注text1为显示框,text2为输入框 我知道问题出在Text1.Text = "时间" & c & "(" & a & ")" & "内容:" & b,看怎样解决??
应为VB@newline

text1为显示框,text2为输入框的mutiline都要设为true。

将text1设为多行(mutiline为TRUE)
Text1.Text = text1.text & "时间" & c & "(" & a & ")" & "内容:" & b & vbcrlf

&vbcrlf 或者&chr(13)是换行
text的属性multline要设置成ture才行

设置Text1.muiltline = true.
做个显示过程:
Private Sub msg(b As String)
'添加新串
Text1.Text = Text1.text & "时间" & DTpicker1.value & "(" & label1.caption & ")" & "内容:" & b & vbcrlf
'把光标移到最后。就是要显示最新更新内容
Text1.SelStart = Len(Text1.Text)
'刷新
DoEvents
End Sub

程序里直接调用, 就行了。
Private Sub Command1_Click()
msg text2.text
End Sub