Results 1 to 13 of 13

Thread: String cannot be converted to label?

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    45

    String cannot be converted to label?

    I have an array of numbers of which I want displayed in a text box but when I call for the numbers in my array, I get a compiler error "Type "String" cannot be converted to label".

    How can I get my array value printed onto my text box? Where am I going wrong? Here is the code:
    Code:
    Public Class frmBaseExponent
        Dim LabelArray(8) As Label
        Private Sub frmBaseExponent_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           
    
        End Sub
    
        Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
            Dim intExponent, intBase As Integer
    
            If Integer.TryParse(txtExponentInput.Text, intExponent) AndAlso Integer.TryParse(txtBaseInput.Text, intBase) Then
                SetControlArray()
                For i As Int16 = 0 To 8
    
                    LabelArray(i).Text = (CInt(intBase) ^ (CInt(intExponent) + i)).ToString
    
                Next
            Else
                MessageBox.Show("Please enter a valid numeric value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtExponentInput.SelectAll()
                txtExponentInput.Focus()
            End If
    
    
    
        End Sub
    
        Sub SetControlArray()
    
            LabelArray(0) = txtAnswer1.Text
    
            LabelArray(1) = txtAnswer2.Text
    
            LabelArray(2) = txtAnswer3.Text
    
            LabelArray(3) = txtAnswer4.Text
    
            LabelArray(4) = txtAnswer5.Text
    
            LabelArray(5) = txtAnswer6.Text
    
            LabelArray(6) = txtAnswer7.Text
    
            LabelArray(7) = txtAnswer8.Text
    
            LabelArray(8) = txtAnswer9.Text
    
        End Sub
    End Class
    Last edited by hoodborn; Jan 30th, 2010 at 11:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width