3 Replies - 23449 Views - Last Post: 17 December 2008 - 06:32 PM Rate Topic: -----

#1 raziel6669  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-December 08

Error 1 Value of type 'String' cannot be converted to 'Sys

Posted 17 December 2008 - 05:35 PM

Option Explicit On
Option Strict On

Public Class MainForm

	Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
		Me.Close()
	End Sub

	Private Sub selectButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles selectButton.Click
		' generates six random numbers from 1 through 54

		Dim randomGenerator As Random
		Dim num1 As Integer
		Dim num2 As Integer
		Dim num3 As Integer
		Dim num4 As Integer
		Dim num5 As Integer
		Dim num6 As Integer


		' generate random numbers
		num1 = randomGenerator.Next(1, 55)
		num2 = randomGenerator.Next(1, 55)
		num3 = randomGenerator.Next(1, 55)
		num4 = randomGenerator.Next(1, 55)
		num5 = randomGenerator.Next(1, 55)
		num6 = randomGenerator.Next(1, 55)

		' display random numbers
		numbersLabel = Convert.ToString(num1) & "  " & Convert.ToString(num2) _
			& "  " & Convert.ToString(num3) & "  " & Convert.ToString(num4) _
			& "  " & Convert.ToString(num5) & "  " & Convert.ToString(num6)

	End Sub
End Class
 


I have some issue with the code following.. the error i keep getting is Error 1 Value of type 'String' cannot be converted to 'System.Windows.Forms.Label'.

I cant seem to find the syntax error im sure its small but i keep missing it..


  ' display random numbers
		numbersLabel = Convert.ToString(num1) & "  " & Convert.ToString(num2) _
			& "  " & Convert.ToString(num3) & "  " & Convert.ToString(num4) _
			& "  " & Convert.ToString(num5) & "  " & Convert.ToString(num6)




thanks, raz

Is This A Good Question/Topic? 0
  • +

Replies To: Error 1 Value of type 'String' cannot be converted to 'Sys

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Error 1 Value of type 'String' cannot be converted to 'Sys

Posted 17 December 2008 - 05:59 PM

Your problem lies here

numbersLabel = Convert.ToString(num1) & "  " & Convert.ToString(num2) _
            & "  " & Convert.ToString(num3) & "  " & Convert.ToString(num4) _
            & "  " & Convert.ToString(num5) & "  " & Convert.ToString(num6)



You forgot to add the .Text of the label. Try this

numbersLabel.Text = Convert.ToString(num1) & "  " & Convert.ToString(num2) _
            & "  " & Convert.ToString(num3) & "  " & Convert.ToString(num4) _
            & "  " & Convert.ToString(num5) & "  " & Convert.ToString(num6)


Was This Post Helpful? 1
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Error 1 Value of type 'String' cannot be converted to 'Sys

Posted 17 December 2008 - 06:05 PM

Modified title to be more descriptive of the problem.
Was This Post Helpful? 0
  • +
  • -

#4 raziel6669  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-December 08

Re: Error 1 Value of type 'String' cannot be converted to 'Sys

Posted 17 December 2008 - 06:32 PM

never mind, figured that one out.

Thank a bunch guys, you are excellent.

still trying to get the hang of VB vs C++.

This post has been edited by raziel6669: 17 December 2008 - 06:35 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1