tags:

views:

21

answers:

1

How can I add a string to my visual basic form?

I'm creating a study application for myself and this is what I have:

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

End Class

I'm trying to display a line of text on my form saying.. "Prevented firefox from running X times.

X being my "amounts" variable.

Here's what my form looks like:

So how can I put my amounts variable in place of the X?

+1  A: 

Assuming that you have a label named 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")
Fredrik Mörk
Wow thanks a lot:)
Kyle
@rockinthesixstring: nice edit, thanks :)
Fredrik Mörk