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 you make an array of properties?

can you make an array of properties?

Scheduled Pinned Locked Moved Visual Basic
csharpcssvisual-studiodata-structureshelp
2 Posts 1 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.
  • N Offline
    N Offline
    Nadroj
    wrote on last edited by
    #1

    this is my first post... im kinda new to VS.net, so take it easy ;P. i have only worked with the vb console apps to date. i was just wondering if there is a way to make an array out of a property procedure? i mean, i declare my property procedure named Score, which is a variable to store a test score, as a percentage. I want to have 3 test scores, and make an array so its easier later in the code when working with them. the reason i want a property method is so i can prevent scores > 100 and < 0. before using properties, i simply made a variable array named Score, storing 3 values of test scores. i want to do this exact same thing, but limiting input, using properties. this is what i have so far: Property Score() As single Get Return tempScore End Get Set(ByVal Value As String) If Value < 0 Then Console.WriteLine("Score average cannot be less than 0%.") tempScore = 0 ElseIf Value > 100 Then Console.WriteLine("Score average cannot be greater than 100%.") tempScore = 100 Else tempScore = Value End If End Set End Property ANY HELP is SINCERLY appreciated. sorry if its unclear, as im not used to this. Thank you. Jordan. III

    N 1 Reply Last reply
    0
    • N Nadroj

      this is my first post... im kinda new to VS.net, so take it easy ;P. i have only worked with the vb console apps to date. i was just wondering if there is a way to make an array out of a property procedure? i mean, i declare my property procedure named Score, which is a variable to store a test score, as a percentage. I want to have 3 test scores, and make an array so its easier later in the code when working with them. the reason i want a property method is so i can prevent scores > 100 and < 0. before using properties, i simply made a variable array named Score, storing 3 values of test scores. i want to do this exact same thing, but limiting input, using properties. this is what i have so far: Property Score() As single Get Return tempScore End Get Set(ByVal Value As String) If Value < 0 Then Console.WriteLine("Score average cannot be less than 0%.") tempScore = 0 ElseIf Value > 100 Then Console.WriteLine("Score average cannot be greater than 100%.") tempScore = 100 Else tempScore = Value End If End Set End Property ANY HELP is SINCERLY appreciated. sorry if its unclear, as im not used to this. Thank you. Jordan. III

      N Offline
      N Offline
      Nadroj
      wrote on last edited by
      #2

      ok.. i guess i got it working. here it is, if anyone cares: Private tempScore(3) As Integer Property score(ByVal i As Byte) As String Get Return tempScore(i) End Get Set(ByVal Value As String) If Value < 0 Then Console.WriteLine("Score average cannot be less than 0%.") tempScore(i) = 0 ElseIf Value > 100 Then Console.WriteLine("Score average cannot be greater than 100%.") tempScore(i) = 100 Else tempScore(i) = Value End If End Set End Property Jordan. III

      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