Click here to Skip to main content
15,893,923 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Recursive Function Pin
Andy_L_J5-Apr-10 2:35
Andy_L_J5-Apr-10 2:35 
GeneralRe: Recursive Function [modified] Pin
riced5-Apr-10 4:19
riced5-Apr-10 4:19 
AnswerRe: Recursive Function Pin
William Winner7-Apr-10 8:18
William Winner7-Apr-10 8:18 
QuestionGet the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 0:51
norrisMiou4-Apr-10 0:51 
AnswerRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 2:28
professionalDaveAuld4-Apr-10 2:28 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou4-Apr-10 2:56
norrisMiou4-Apr-10 2:56 
GeneralRe: Get the parent objet or parent level in nested lists Pin
DaveAuld4-Apr-10 5:36
professionalDaveAuld4-Apr-10 5:36 
AnswerRe: Get the parent objet or parent level in nested lists Pin
Alan N4-Apr-10 6:04
Alan N4-Apr-10 6:04 
Hi,
Maybe there is no need to store the level, just calculate the value when it's needed by walking up the list of nodes via the Parent property. The root or top node has no parent and the Parent property will return null or Nothing when you get there.

The first example using a loop is probably easier to understand than the second recursive version.
C#
public Int32 Level() {
  Int32 levelValue = 0;
  Node node = this;
  while (node.Parent != null) {
    levelValue = levelValue + 1;
    node = node.Parent;
  }
  return levelValue;
}

C#
public Int32 Level() {
  if (this.Parent == null) {
    return 0;
  } else {
    return Level() + 1;
  }
}

Sorry about using c# in the Basic forum. If you can't decipher it, post back and I'll attempt a translation.

Alan.
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 7:26
norrisMiou5-Apr-10 7:26 
GeneralRe: Get the parent objet or parent level in nested lists Pin
Alan N5-Apr-10 13:19
Alan N5-Apr-10 13:19 
GeneralRe: Get the parent objet or parent level in nested lists Pin
norrisMiou5-Apr-10 15:29
norrisMiou5-Apr-10 15:29 
QuestionLinking Databases to VB Applications Pin
Razanust3-Apr-10 19:36
Razanust3-Apr-10 19:36 
AnswerRe: Linking Databases to VB Applications Pin
riced3-Apr-10 23:59
riced3-Apr-10 23:59 
AnswerRe: Linking Databases to VB Applications Pin
εїзεїзεїз4-Apr-10 0:19
εїзεїзεїз4-Apr-10 0:19 
GeneralRe: Linking Databases to VB Applications Pin
Razanust4-Apr-10 4:40
Razanust4-Apr-10 4:40 
GeneralRe: Linking Databases to VB Applications Pin
riced4-Apr-10 4:57
riced4-Apr-10 4:57 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:09
sitebuilderLuc Pattyn4-Apr-10 5:09 
AnswerRe: Linking Databases to VB Applications Pin
Luc Pattyn4-Apr-10 5:13
sitebuilderLuc Pattyn4-Apr-10 5:13 
GeneralRe: Linking Databases to VB Applications Pin
Razanust4-Apr-10 8:15
Razanust4-Apr-10 8:15 
QuestionProblem with unrar.dll and decompressor-class Pin
Maik Lange2-Apr-10 19:38
Maik Lange2-Apr-10 19:38 
AnswerRe: Problem with unrar.dll and decompressor-class Pin
Dave Kreskowiak3-Apr-10 3:02
mveDave Kreskowiak3-Apr-10 3:02 
AnswerRe: Problem with unrar.dll and decompressor-class Pin
Luc Pattyn3-Apr-10 4:59
sitebuilderLuc Pattyn3-Apr-10 4:59 
QuestionVB6 Extend maximum height of PictureBox Pin
Bob Hiller2-Apr-10 16:14
Bob Hiller2-Apr-10 16:14 
AnswerRe: VB6 Extend maximum height of PictureBox Pin
Dave Kreskowiak3-Apr-10 3:01
mveDave Kreskowiak3-Apr-10 3:01 
GeneralRe: VB6 Extend maximum height of PictureBox Pin
Luc Pattyn3-Apr-10 5:01
sitebuilderLuc Pattyn3-Apr-10 5:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.