Click here to Skip to main content
15,903,362 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to convert .sql to .mdb file Pin
preci23-Apr-07 5:22
preci23-Apr-07 5:22 
AnswerRe: how to convert .sql to .mdb file Pin
Dave Kreskowiak23-Apr-07 5:34
mveDave Kreskowiak23-Apr-07 5:34 
QuestionDialing a Phone Number from Visual Basic Pin
S.Rajeshwar23-Apr-07 5:14
S.Rajeshwar23-Apr-07 5:14 
AnswerRe: Dialing a Phone Number from Visual Basic Pin
Dave Kreskowiak23-Apr-07 5:37
mveDave Kreskowiak23-Apr-07 5:37 
GeneralRe: Dialing a Phone Number from Visual Basic Pin
keninfo24-Apr-07 2:07
keninfo24-Apr-07 2:07 
QuestionProblem with dt.Rows.Count Pin
RichardBerry23-Apr-07 1:36
RichardBerry23-Apr-07 1:36 
AnswerRe: Problem with dt.Rows.Count Pin
andyharman23-Apr-07 2:53
professionalandyharman23-Apr-07 2:53 
AnswerRe: Problem with dt.Rows.Count Pin
Dave Kreskowiak23-Apr-07 5:51
mveDave Kreskowiak23-Apr-07 5:51 
RichardBerry wrote:
SURELY THE EXPRESSION Me.dtPackBom2.Rows.Count - 1 IS EVALUATED EACH TIME THE LOOP IS EXECUTED?


Don't count on it. If you're removing items from a list, it's better to start at the end and work your way back to 0. The way you're doing it now, you'll skip items in the list when you remove one. Say you have 5 items in your list, indexed 0 to 4, and you're going to end up removing item 2:
Index    Items
-----    -----
  0      "This"
  1      "is"
  2      "was"
  3      "a"
  4      "test"

Your counter, BomRow, has the value of 2 when you make a check and decide that you want to remove the item at that index. Now, after you remove the item, the Items.Count now says 4. Great! Who cares... You're array now looks like this after you remove the item, but BEFORE you get to the Next statement.
Index    Items
-----    -----
  0      "This"
  1      "is"
  2      "a"
  3      "test"

You finally reach the Next statement and increment BomRow. It's now 3, BUT since the items have moved down the list, you're not checking the item that just got moved to position 2 in the index! You've just skipped an item!

It's better to start at the end of the array and work your way back to 0. That way, you won't be skipping any items, no matter how many items you had to start with and how many you remove in each iteration of the loop.


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


GeneralRe: Problem with dt.Rows.Count Pin
RichardBerry23-Apr-07 22:05
RichardBerry23-Apr-07 22:05 
QuestionData type mismatch in criteria expression. Pin
peteyshrew22-Apr-07 23:40
peteyshrew22-Apr-07 23:40 
AnswerRe: Data type mismatch in criteria expression. Pin
Colin Angus Mackay23-Apr-07 0:21
Colin Angus Mackay23-Apr-07 0:21 
AnswerRe: Data type mismatch in criteria expression. Pin
RichardBerry23-Apr-07 1:39
RichardBerry23-Apr-07 1:39 
GeneralRe: Data type mismatch in criteria expression. Pin
Colin Angus Mackay23-Apr-07 3:35
Colin Angus Mackay23-Apr-07 3:35 
GeneralRe: Data type mismatch in criteria expression. Pin
ChandraRam23-Apr-07 3:43
ChandraRam23-Apr-07 3:43 
GeneralRe: Data type mismatch in criteria expression. Pin
Colin Angus Mackay23-Apr-07 4:02
Colin Angus Mackay23-Apr-07 4:02 
QuestionCrystal Reports Exporting Problem Pin
freefika22-Apr-07 23:01
freefika22-Apr-07 23:01 
QuestionVery URGENT.......Serial Port Buffer Pin
navyasri22-Apr-07 21:55
navyasri22-Apr-07 21:55 
AnswerRe: Very URGENT.......Serial Port Buffer Pin
Patrick Etc.23-Apr-07 18:49
Patrick Etc.23-Apr-07 18:49 
QuestionFace detection algorithm? Pin
tuanlm7522-Apr-07 20:28
tuanlm7522-Apr-07 20:28 
AnswerRe: Face detection algorithm? Pin
Christian Graus22-Apr-07 23:09
protectorChristian Graus22-Apr-07 23:09 
QuestionCustom reporting tools [modified] Pin
shreekar22-Apr-07 19:59
shreekar22-Apr-07 19:59 
QuestionWHAT IS THE EQUIVALENT OF THIS CODE IN VB.NET Pin
klaydze22-Apr-07 19:54
klaydze22-Apr-07 19:54 
AnswerRe: WHAT IS THE EQUIVALENT OF THIS CODE IN VB.NET Pin
MatrixCoder22-Apr-07 20:11
MatrixCoder22-Apr-07 20:11 
QuestionHelp with service and logged in user Pin
dBrong22-Apr-07 18:35
dBrong22-Apr-07 18:35 
AnswerRe: Help with service and logged in user Pin
coolestCoder22-Apr-07 19:17
coolestCoder22-Apr-07 19:17 

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.