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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Rather Frustrating Issue

Rather Frustrating Issue

Scheduled Pinned Locked Moved Visual Basic
helpquestiondatabasedata-structures
3 Posts 3 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.
  • D Offline
    D Offline
    Diagathon
    wrote on last edited by
    #1

    Alright, basically I am trying to create a function that does the following: The user has a rank The possible ranks a user can have are stored in an array ("RankTree()") The Public Sub in the class is called Promote(Byval Position As String) My problem is that I'm trying to make the sub find the index of the user's rank in RankTree, then move foreward one index, and set the user's Position (Dude.Position) to the next rank in the array. How do I go about doing this?

    D C 2 Replies Last reply
    0
    • D Diagathon

      Alright, basically I am trying to create a function that does the following: The user has a rank The possible ranks a user can have are stored in an array ("RankTree()") The Public Sub in the class is called Promote(Byval Position As String) My problem is that I'm trying to make the sub find the index of the user's rank in RankTree, then move foreward one index, and set the user's Position (Dude.Position) to the next rank in the array. How do I go about doing this?

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

      Diagathon wrote:

      The possible ranks a user can have are stored in an array ("RankTree()")

      Why is this an Array? Why couldn't you use an Enum?

      Diagathon wrote:

      The Public Sub in the class is called Promote(Byval Position As String) My problem is that I'm trying to make the sub find the index of the user's rank in RankTree

      All you have to do is enumerate (For i=0 to ...) the string (I'm assuming they're strings!) in the array and check the current Position to each one in the array. When you find it, I contains the index. All you have to do is increment it. This problem would probably be better suited for an Enum...

      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      1 Reply Last reply
      0
      • D Diagathon

        Alright, basically I am trying to create a function that does the following: The user has a rank The possible ranks a user can have are stored in an array ("RankTree()") The Public Sub in the class is called Promote(Byval Position As String) My problem is that I'm trying to make the sub find the index of the user's rank in RankTree, then move foreward one index, and set the user's Position (Dude.Position) to the next rank in the array. How do I go about doing this?

        C Offline
        C Offline
        Code_Doctor
        wrote on last edited by
        #3

        I'll suggest using a LinkedList. Here is an example: First define a class to hold your object. Public Class Dude Public _Name As String Public _Position As Integer Public Sub New(ByVal Name As String, ByVal Position As Integer) _Name = Name _Position = Position End Sub End Class Then in your main app, define the LinkedList to hold these individual objects. Dim MyDudes as New LinkList(Of Dude) You can add items to this several ways: MyDudes.AddFirst(NewDude) MyDudes.AddAfter(PreviousDude,NewDude) MyDudes.AddBefore(BeforeDude,NewDude) MyDudes.AddLast(NewDude) There are Find Methods, and Remove methods that can easily help with what you need. Hope this helps! :) ~ CodeDoctor ~

        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