locked
value of type integer cannot be converted to 1-dimensional array of integer - error in vb.net RRS feed

  • Question

  • User-270722712 posted

    Hello 

    in my Vacancy.vb file the method for location datatype is defined as following

        Public Property LocationID() As Integer()
            Get
                Return _locationid
            End Get
            Set(ByVal value As Integer())
                _locationid = value
            End Set
        End Property

    In samplevacancy.aspx.vb file I am trying to hardcode the location value

      With Vacancy 
         .LocationID = 5
      End With
    

    But this line shows this error  " value of type integer cannot be converted to 1-dimensional array of integer "

    I need to hardcode this value. 

    How can I fix this. 

    I have to call this Vacancy.vb methods to save this record into database.

    Monday, August 24, 2015 5:27 AM

Answers

  • User-1716253493 posted

    try this

        Public Property LocationID() As Integer
            Get
                Return _locationid
            End Get
            Set(ByVal value As Integer)
                _locationid = value
            End Set
        End Property

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2015 6:35 AM

All replies

  • User-1716253493 posted

    try this

        Public Property LocationID() As Integer
            Get
                Return _locationid
            End Get
            Set(ByVal value As Integer)
                _locationid = value
            End Set
        End Property

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 24, 2015 6:35 AM
  • User-270722712 posted

    Thanks so much. But If I do that my entire background coding needs to change.

    I have found this solution

                .LocationID = {5}
    

    By this line of code i was able to hardcode the value for location id and there was no need to change my entire background code.

    Monday, August 24, 2015 7:15 AM