Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. can't modify property in property window

can't modify property in property window

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scott987uk
    wrote on last edited by
    #1

    iv created a UserControl with in it iv made a Property with a get and set. If i create it with a return type and input type of an Integer i can modify the property from the property window . . however this is a problem becuase the value that could be inputed could be eather a string or an integer. Thefore i made it so that the value to be input and returned would be an object. Hoever when i came to look at the property window i was unable to change the value becuase it is now an object i assume. is there any way around this plz, apart from creating 2 propertys. the code below is what iv done. Thanks for any help that any one can give Scott Public Property NumberToDisplay() As Object Set(ByVal Number As Object) If TypeOf Number Is Integer Then If (Number < 0) Or (Number > 9) Then sErrormessage = "Recived number out side of range of 0 to 9" RaiseEvent ErrorOccourd(sErrormessage) Else iNumberToBeDisplayed = Number Me.Invalidate() End If ElseIf TypeOf Number Is String Then 'if Number can not be converted to a string an error will occour 'e.g. inputing a "." Try Dim iNumber As Integer iNumber = Int32.Parse(Number) If (iNumber < 0) Or (iNumber > 9) Then sErrormessage = "Recived number out side of range of 0 to 9" RaiseEvent ErrorOccourd(sErrormessage) Else iNumberToBeDisplayed = iNumber Me.Invalidate() End If Catch ex As Exception sErrormessage = "The input value from the string could not be converted to a number" RaiseEvent ErrorOccourd(sErrormessage) End Try End If End Set Get Return iNumberToBeDisplayed End Get End Property

    D 1 Reply Last reply
    0
    • S scott987uk

      iv created a UserControl with in it iv made a Property with a get and set. If i create it with a return type and input type of an Integer i can modify the property from the property window . . however this is a problem becuase the value that could be inputed could be eather a string or an integer. Thefore i made it so that the value to be input and returned would be an object. Hoever when i came to look at the property window i was unable to change the value becuase it is now an object i assume. is there any way around this plz, apart from creating 2 propertys. the code below is what iv done. Thanks for any help that any one can give Scott Public Property NumberToDisplay() As Object Set(ByVal Number As Object) If TypeOf Number Is Integer Then If (Number < 0) Or (Number > 9) Then sErrormessage = "Recived number out side of range of 0 to 9" RaiseEvent ErrorOccourd(sErrormessage) Else iNumberToBeDisplayed = Number Me.Invalidate() End If ElseIf TypeOf Number Is String Then 'if Number can not be converted to a string an error will occour 'e.g. inputing a "." Try Dim iNumber As Integer iNumber = Int32.Parse(Number) If (iNumber < 0) Or (iNumber > 9) Then sErrormessage = "Recived number out side of range of 0 to 9" RaiseEvent ErrorOccourd(sErrormessage) Else iNumberToBeDisplayed = iNumber Me.Invalidate() End If Catch ex As Exception sErrormessage = "The input value from the string could not be converted to a number" RaiseEvent ErrorOccourd(sErrormessage) End Try End If End Set Get Return iNumberToBeDisplayed End Get End Property

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You could either restrict your Property to String type, since your code handles everything as a number internally, or you could make an overloaded Property, one set for handling a String object and another for handling an Integer object. I'd go with making your property a String if you absolutely had to do string convertion to get an Integer out of it. Personally, if your going to be using the input strictly as an Integer, make the Property an Integer and don't mess with functionality you don't really need. RageInTheMachine9532

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups