如何从文本框和richtextbox添加列表框中的项目 [英] How to add items in a listbox from a textbox and a richtextbox
问题描述
我正在尝试创建一个表单,可以在richtextbox中输入注释/抱怨,用户也应该输入用户名。这是我累了,但代码有这个错误(运营商&'没有为'string()'和'string'定义)
我希望输出如下
用户名:评论
username2:comments
请帮忙!
Private Sub btncomment_Click(发件人为对象,e为EventArgs)处理btncomment.Click
     如果TextBox1.Text =""然后
          MsgBox("输入用户名!")
     否则
          ListBox1.Items.AddRange(TextBox1.Text.Split&":"& RichTextBox1.Text.Split)
     结束如果
 结束子
< blockquote>
我正在尝试创建一个表单,可以在richtextbox中输入注释/抱怨,用户也应该输入用户名。这是我累了,但代码有这个错误(运营商&'没有为'string()'和'string'定义)
我希望输出如下
用户名:评论
username2:comments
请帮忙!
Private Sub btncomment_Click(发件人为对象,e为EventArgs)处理btncomment.Click
&NBSP; &NBSP; &NBSP;如果TextBox1.Text =""然后
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MsgBox("输入用户名!")
&NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; ListBox1.Items.AddRange(TextBox1.Text.Split&":"& RichTextBox1.Text.Split)
&NBSP; &NBSP; &NBSP;结束如果
&NBSP;结束次级
你是什么试图添加到列表框? 像"rkimble:这是我的评论"这样的字符串或者单词列表?
如果你只想要字符串,那就是:
ListBox1.Items.Add (TextBox1.Text&":"& RichTextBox1.Text)
如果这不是你想要的,你能否让我们更好地了解应该是什么在列表框中?
i am trying to create a form where one can input comments/complains in a richtextbox and the user should also enter the username. Here is what i have tired but the code has this error (Operator '&' is not defined for 'string()' and 'string')
i want the output to be as follows
username:comments
username2:comments
please help!
Private Sub btncomment_Click(sender As Object, e As EventArgs) Handles btncomment.ClickIf TextBox1.Text = "" Then
MsgBox("Enter a username!")
Else
ListBox1.Items.AddRange(TextBox1.Text.Split & ":" & RichTextBox1.Text.Split)
End If
End Sub
i am trying to create a form where one can input comments/complains in a richtextbox and the user should also enter the username. Here is what i have tired but the code has this error (Operator '&' is not defined for 'string()' and 'string')
i want the output to be as follows
username:comments
username2:comments
please help!
Private Sub btncomment_Click(sender As Object, e As EventArgs) Handles btncomment.Click
If TextBox1.Text = "" Then
MsgBox("Enter a username!")
Else
ListBox1.Items.AddRange(TextBox1.Text.Split & ":" & RichTextBox1.Text.Split)
End If
End Sub
What are you trying to add to the listbox? A string like "rkimble:This is my comment" or a list of words?
If you just want the string it would be:
ListBox1.Items.Add(TextBox1.Text & ":" & RichTextBox1.Text)
If that's not what you want, can you give us a better idea of what should be in the listbox?
这篇关于如何从文本框和richtextbox添加列表框中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!