Wrox Programmer Forums
|
Visual Basic 2010 General Discussion For any discussions about Visual Basic 2010 topics which aren't related to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 23rd, 2010, 08:12 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Visual Studio is just giving up!

Hi all,

My problem is, I have to iterations one inside another!
The iterations are looping through a list of my own classes! both of them!
So basically its comparing one class to all the other classes in the other list and looping through as shown below!

Code:
Dim MyList As List(Of MusicDetail) = MyProperty
Dim MyList2 As List(Of MusicDetail) = MyProperty2

For Each nMusDetail As MusicDetail In MyList
    For Each nMusDetail2 As MusicDetail In MyList2

    Next
Next
Now Regardless of the names and what happens in the middle of the two iterations, VB does not want to go any further than the second "for each" statement! It just exits out of the code with no errors, or message boxes!

Any Ideas?!

Cheers
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old December 28th, 2010, 07:40 AM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default Quirks,

I have been Programming in visual basic 6 for some time. when I find a spot like this where visual basic "gives up" I use a work around ie.

Code:
For Each nMusDetail As MusicDetail In MyList
    Do 
          If condition = true Then
               Exit Do
           Else 
               ' Do Something Wonderful'
           End IF
    Loop
Next
 
Old December 29th, 2010, 08:04 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

But that doesn't quite do the comparison I'm looking for, there should be no reason for visual studio to give up!

I need to do a specific comparison between the two classes and the for each statement nicely grabs each one for me with out having add extra code to get them.
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old December 29th, 2010, 01:09 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

Quote:
Originally Posted by Apocolypse2005 View Post
Hi all,

My problem is, I have to iterations one inside another!
The iterations are looping through a list of my own classes! both of them!
So basically its comparing one class to all the other classes in the other list and looping through as shown below!

Code:
Dim MyList As List(Of MusicDetail) = MyProperty
Dim MyList2 As List(Of MusicDetail) = MyProperty2

For Each nMusDetail As MusicDetail In MyList
    For Each nMusDetail2 As MusicDetail In MyList2

    Next
Next
Now Regardless of the names and what happens in the middle of the two iterations, VB does not want to go any further than the second "for each" statement! It just exits out of the code with no errors, or message boxes!

Any Ideas?!

Cheers
It is possible to nest them.

See: For Each...Next Statement (Visual Basic)
*** scroll down to Nesting Loops


The basic syntax is:
Code:
For Each element [ As datatype ] In group
    [ statements ]
    [ Continue For ]
    [ statements ]
    [ Exit For ]
    [ statements ]
Next [ element ]
Notice how the Next [ element ] has the optional element. I would suggest adding this to make sure that the compiler does not get confused.

Code:
Dim MyList As List(Of MusicDetail) = MyProperty
Dim MyList2 As List(Of MusicDetail) = MyProperty2

For Each nMusDetail As MusicDetail In MyList
    For Each nMusDetail2 As MusicDetail In MyList2

    Next nMusDetail2 
Next nMusDetail
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015
 
Old December 30th, 2010, 09:39 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Red face

Sorry for taking your time.

It appears that when I last had a break from coding this piece of software, I left it mid debugging when I had found the problem, but I must have been so tired that I couldn't be bothered to work the solution, subsequently I forgot about having ever discovered where the error was coming from.

So once again after debugging step by step the code and analysing the vairables that were getting iterated through, it was bought to my attention that the second iteration was trying to extract the class from an uninstantiated list - which is impossible!

After tracing back to where these variable lists were getting their 'filling' from it was traced back to a dialog and its properties - where inlaid the problem! This solution was upgraded from VS2008 however my coding practices weren't and after much modification using old practices this error arose. It turns out that VS2010 VB.net has this new feature for properties, where unless specifiying the get and set properties they're already done for you! I must have when creating these properties overlooked the fact that I hadn't set or get its information - I must have been rushing as I usually do . . . :)

The fragmented extract below shows my code - the blunder and the solution

Code:
Public MyProperty As List(Of MyVariables)
Private p_myproperty As List(Of MyVariables)

. . . *inside the function

  p_myproperty = theFilling
  Me.Close

. . . 

======================================
' The Correction

Public MyProperty As List(Of MyVariables)

. . . *inside the function

  MyProperty = theFilling
  Me.Close

. . .
If you've understood any of what I've been rambling on about then maybe this can provide some insight if any of your code goes wrong when it comes to assigning properties

However this is a pretty basic mistake which has spawned from a change in coding practices bought on by the upgrading of VS - again my bad for wasting your valuable time

Cheers
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old December 30th, 2010, 09:43 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Exclamation

Quote:
Originally Posted by Apocolypse2005 View Post
It just exits out of the code with no errors, or message boxes!

Any Ideas?!
This does bring up a surprising question - How come VB didn't encounter an error when trying to iterate through - "An Object who's properies or methods havent been . . . . I have forgotton the rest" but you get the picture

Any Ideas?! - don't waste your time by answering that it could just be a 1 off

Cheers
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old January 2nd, 2011, 07:35 AM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default I feel your frustration.

There havde been many times when I am coding that VB "Gives up". I look And hunt and use every shred of debugging savy I can muster, but can find NO REASON for VB not to give any results.... sometimes re-booting vs2010 solves the issue. it has gotten to the point when I am programming and my temper starts getting hot & ugly my wife will ask "Do you need to re-boot?"

I've never posted this or mentioned it to microsoft because I can never reproduce the error. thought it was something I was doing/not doing





Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual studio 2005(32 bit) code not work in visual studio 2008 on windows server 2008 gr8.jain Visual Basic 2008 Essentials 1 August 31st, 2009 10:07 AM
FTP in Visual Studio 2005 Pro (Visual Basic) shoopes VB How-To 1 June 29th, 2006 02:08 PM
Visual Studio 2003 vs. Visual Studio 2005 eitanbarazani C# 2005 4 May 9th, 2006 01:34 AM
Visual Studio .net2003 and Visual Studio 2005 Gert Visual C++ 1 January 24th, 2006 05:10 AM
Visual studio 6 or visual studio .NET chaitannyam Visual C++ 1 November 13th, 2005 09:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.