代码之家  ›  专栏  ›  技术社区  ›  Kyle

将字符串添加到Visual Basic窗体

  •  0
  • Kyle  · 技术社区  · 16 年前

    如何向Visual Basic窗体添加字符串?

    我正在为自己创建一个学习应用程序,这就是我所拥有的:

    Imports System.Diagnostics
    Public Class Form1
    
    Dim amounts As Integer
    
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Processes.Tick
        Dim proc() As Process = Process.GetProcesses
        Dim newproc As New Process
        amounts = 0
        For Each newproc In proc
            If newproc.ProcessName = "firefox" Then
                newproc.Kill()
                amounts = +1
    
            Else
    
            End If
        Next
    End Sub
    
    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    
    End Sub
    

    结束类

    我正试图在我的表单上显示一行文本,并说……阻止火狐运行x次。

    x是我的“数量”变量。

    我的表格是这样的: http://img696.imageshack.us/img696/8162/programq.png

    那么,我怎样才能用我的数量变量来代替x呢?

    2 回复  |  直到 10 年前
        1
  •  1
  •   Chase Florell    16 年前

    假设您有一个名为 yourLabel :

    ''# my personally preferred way
    yourLabel.Text = String.Format("Prevented FireFox from running {0} times", _
                                   amounts)
    
    ''# straight-forward concatenation
    yourLabel.Text = "Prevented FireFox from running " & amount & " times"
    
    ''# using String.Concat (which is what the above code will be compiled to)
    yourLabel.Text = String.Concat("Prevented FireFox from running ",amount," times")
    
        2
  •  0
  •   Manju Mohan    10 年前

    试试看吧

    msgbox("Prevented FireFox from running " & amount & " times")