lbl problem

robertuk702

Member
Joined
Apr 23, 2006
Messages
15
Programming Experience
Beginner
Hi,

I am having trouble with outputting a label on screen.

Basically
lblwimax.Text = "This distance is " & distance & "miles. Will there be a sigal strength? " & signal

signal does not exist as such and has a blue line under it. the program still runs though. I enter distance as a value of 16 and I get a message saying "This is the distance 16" - but i havent specifed it like that anywhere in the program. as you can see the first part says 'This distance is"

Is there any reason for this?

Thank you.

Regards.
 
project

Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form

#
Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TxtDistance As System.Windows.Forms.TextBox
Friend WithEvents lblwimax As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.Label3 = New System.Windows.Forms.Label
Me.TxtDistance = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.lblwimax = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Yellow
Me.Label1.Location = New System.Drawing.Point(136, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(344, 56)
Me.Label1.TabIndex = 0
Me.Label1.Text = "IEEE 802.16 Wimax"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.ForeColor = System.Drawing.Color.Yellow
Me.Label2.Location = New System.Drawing.Point(32, 104)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(504, 56)
Me.Label2.TabIndex = 1
Me.Label2.Text = "This program will demonstrate a simple Wimax theory. The user will enter a dista" & _
"nce and will get an answer back to say whether or not they would be within the r" & _
"ange that Wimax can transmit over."
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(24, 168)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(168, 280)
Me.PictureBox1.TabIndex = 2
Me.PictureBox1.TabStop = False
'
'PictureBox2
'
Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
Me.PictureBox2.Location = New System.Drawing.Point(344, 176)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(136, 192)
Me.PictureBox2.TabIndex = 3
Me.PictureBox2.TabStop = False
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 22.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.ForeColor = System.Drawing.Color.Yellow
Me.Label3.Location = New System.Drawing.Point(208, 208)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(120, 32)
Me.Label3.TabIndex = 4
Me.Label3.Text = ">>>>>>"
'
'TxtDistance
'
Me.TxtDistance.Location = New System.Drawing.Point(240, 472)
Me.TxtDistance.Name = "TxtDistance"
Me.TxtDistance.TabIndex = 5
Me.TxtDistance.Text = ""
'
'Label4
'
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.ForeColor = System.Drawing.Color.Yellow
Me.Label4.Location = New System.Drawing.Point(136, 472)
Me.Label4.Name = "Label4"
Me.Label4.TabIndex = 6
Me.Label4.Text = "Enter Distance"
'
'Button1
'
Me.Button1.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.Button1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Button1.Location = New System.Drawing.Point(208, 512)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(160, 56)
Me.Button1.TabIndex = 7
Me.Button1.Text = "Distance OK?"
'
'lblwimax
'
Me.lblwimax.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblwimax.ForeColor = System.Drawing.Color.Yellow
Me.lblwimax.Location = New System.Drawing.Point(216, 592)
Me.lblwimax.Name = "lblwimax"
Me.lblwimax.Size = New System.Drawing.Size(200, 32)
Me.lblwimax.TabIndex = 8
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.ClientSize = New System.Drawing.Size(584, 630)
Me.Controls.Add(Me.lblwimax)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TxtDistance)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.PictureBox2)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "`"
Me.ResumeLayout(False)
End Sub
#End Region
Class TCPCli
Shared Sub Main()
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("127.0.0.1", 8000)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
' Do a simple write.
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there")
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Host returned: " + returndata))
Else
If Not networkStream.CanRead Then
Console.WriteLine("cannot not write data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
Console.WriteLine("cannot read data from this stream")
tcpClient.Close()
End If
End If
End If
' pause so user can view the console output
Console.ReadLine()
End Sub
End Class
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim distance As Integer
distance = Val(TxtDistance.Text)
lblwimax.Text = "This distance is " & distance & "miles. Will there be a sigal strength? " & signal
End Sub
End
Class

What it is supposed to do is accept an integer and then connect to the server program on another pc and get a response back to say whether distance is acceptable or not. Signal is the varialble the other program should return.

Thank you.

Regards.
 
Thank you. That corrected the message. Now I just have to get both programs connected. Using pcs as client server, should I convert my project to a console application?

Thank you.
 
Back
Top