Visual Basic中标签中的多个消息 [英] Multiple messages in label in Visual Basic

查看:67
本文介绍了Visual Basic中标签中的多个消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我是一个非常新手的编码器,只有3周的经验。这是我第一次在这里发布这个代码是为了大学任务。我正在使用Visual Studio 2010和Visual Basic设置。



我的问题是,对于我的作业,我需要制作一个由标签组成的状态框,以显示有关该程序的消息。例如如果没有任何内容输入文本框,状态框将显示消息没有输入数据。



我能够显示消息,但分配要求在标签/状态框中连续显示消息。每次我在标签/状态框中显示一条消息时,它都会覆盖旧消息。



有谁知道如何将连续的消息放入标签?



提前谢谢,



新手编码器。

Hi.
I am a very novice coder with only 3 weeks experience. This is the first time I have posted here and this code is for a university assignment. I am using Visual Studio 2010 with visual basic settings.

My problem is that for my assignment, I am required to make a status box made up of a label to display messages regarding the program. e.g. if nothing is inputted into a textbox the status box will show the message "No data has been inputted".

I am able to show the messages alright but the assignment asks to display messages consecutively in the label/status box. Every time I put up a message into the label/status box, it overwrites the old message.

Does anyone know how to put consecutive messages into a label?

Thanks in advance,

A Novice Coder.

推荐答案

用标签中的新文本连接标签中任何现有文本的想法文本框,在vb.net中,你使用&连接。

假设您的标签将在按钮单击时从文本框添加文本,请参阅以下示例:

The idea to concatenate any existing text in the label with new text from the textbox, in vb.net, you use & to concatenate.
Say you label will add text from textbox upon a button click, see the following example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    If TextBox1.Text.Trim.Count > 0 Then
        Label1.Text = Label1.Text & ", " & TextBox1.Text
    End If
End Sub



我将连接包装在If块中,你知道为什么吗? ?



++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++但是,我会回答:

如果我现在正确理解你,你试图将txtScore1.text和txtScore2.text连接到lblBox吧?


I have wrapped the concatenation in an If block, do you know why?

++++++++++++++++++++++++++++++++++++++++++++

I have seen your response, it is not anywhere near your original question. However, I will answer that:
If I understand you correctly now, you are trying to concatenate txtScore1.text and txtScore2.text into the lblBox right?

lblBox.Text = txtScore1.Text & ", " & txtScore2.Text



这与我在上述解决方案中提供的想法不一样。

另外,你应该改进结构对于你的程序,提示是你不必在每个if语句中重复地将文本框文本分配给标签框,只需要在所有if语句的末尾执行一次。具体如何?我会把它作为家庭作业留下来,不是吗。


Isn't this the same idea that I have provided in the above solution.
In addition, you should improve the construction of your program, the hint is you do not have to repeatedly assigning the textbox text to the label box at every if statement, just need to do it once at the end of all the if statements. Specifically how? I shall leave it as homework after all it is, isn't it.


这篇关于Visual Basic中标签中的多个消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆