Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 9
There are 1 users currently browsing forums.
Visual Basic Programming This area is for talking about programming with visual basic.

Reply
  #1  
Old 01-18-2007
SkiesOfBordom's Avatar
Computer Techie
 
Join Date: Dec 2006
Location: NJ
Age: 22
Posts: 65
Rep Power: 4
SkiesOfBordom is on a distinguished road
reverse count 'for' loops?

VB2005 express
how do i make a 'for' loop iterate DOWN (3 - 2 - 1 - 0) rather than UP (0 - 1 - 2 - 3)? 'i' is the flag value such as 8212.

h = 2 ^ dmflags_checklist.Items.Count

For k = 0 To dmflags_checklist.Items.Count - 1
j = i - h
If j < 0 Then
dmflags_checklist.SetItemCheckState(k, CheckState.Unchecked)
j = i + h
h = h \ 2
ElseIf j > 0 Then
dmflags_checklist.SetItemCheckState(k, CheckState.Checked)
h = h \ 2
End If
Next
this snippet is supposed to take a bitmap # such as 8212 and set the checkstate to checked in the flag checklist when the value is positive. BUT i have to work from last index to first for it to work the way i want it to.

or am i barking up the wrong tree?
__________________
--Chris
Reply With Quote
  #2  
Old 01-18-2007
gorda001's Avatar
This user is deprecated.
 
Join Date: Jun 2005
Location: <0x79a3f6>
Posts: 5,064
Rep Power: 11
gorda001 is on a distinguished road
Re: reverse count 'for' loops?

In C++ that would be:
for (int i = dmflags_checklist.Items.Count; i > 0; i--)

so in VB it could be
For i = dmflags_checklist.Items.Count - 1 To 0

I don't know VB but just try it
Reply With Quote
  #3  
Old 01-18-2007
SkiesOfBordom's Avatar
Computer Techie
 
Join Date: Dec 2006
Location: NJ
Age: 22
Posts: 65
Rep Power: 4
SkiesOfBordom is on a distinguished road
Re: reverse count 'for' loops?

well do know that it doesnt like
For i = dmflags_checklist.Items.Count to 0 (totally skips for loop)

tried yours...
same thing.

all the code i provided does is check the ones that make j positive because it goes up not down.
Reply With Quote
  #4  
Old 01-18-2007
gorda001's Avatar
This user is deprecated.
 
Join Date: Jun 2005
Location: <0x79a3f6>
Posts: 5,064
Rep Power: 11
gorda001 is on a distinguished road
Re: reverse count 'for' loops?

Hmm, well then you have to hack it:

Code:
For i = 0 to dmflags_checklist.Items.Count - 1
    x = dmflags_checklist.Items.Count - 1 - i;
then use x as your iterator

EDIT: I noticed you already had a j in your code so I changed it to x

Last edited by gorda001; 01-18-2007 at 11:09 AM.
Reply With Quote
  #5  
Old 01-25-2007
waheedahmed's Avatar
C# += C++ += C ;
 
Join Date: Apr 2006
Location: Pakistan
Posts: 1,002
Rep Power: 6
waheedahmed is on a distinguished road
Re: reverse count 'for' loops?

If you mean making a loop count backwards then use 'step'
Ex. For i = 10 To 0 Step -1, this deducts 1 from i each time the loop completes, you can change the step value, default is 1.

I am not sure if thats what you were trying to do.

Waheed
Reply With Quote
  #6  
Old 01-25-2007
SkiesOfBordom's Avatar
Computer Techie
 
Join Date: Dec 2006
Location: NJ
Age: 22
Posts: 65
Rep Power: 4
SkiesOfBordom is on a distinguished road
Re: reverse count 'for' loops?

@ waheedahmed : wow it worked thankee sir
Reply With Quote
  #7  
Old 01-30-2007
New Born
 
Join Date: Jan 2007
Posts: 3
Rep Power: 0
figueroa.soft is on a distinguished road
Re: reverse count 'for' loops?

do
code goes here
also here you need to code variable - 1
Loop Until variable = the number you wish to stop

These is using Visual Basic.net let me know if this help you
Reply With Quote
  #8  
Old 01-30-2007
New Born
 
Join Date: Jan 2007
Posts: 3
Rep Power: 0
figueroa.soft is on a distinguished road
Re: reverse count 'for' loops?

How can I write in a listbox using an array with out going out of bound. This happen because I'm reading from a textbox using split and when I try to add the chararacter that are in the array to the listbox it said array out of bound. I think it is because in the loop the blank spaces are increasing the counter but the array really have less character inside. What I would like to do is subtract 1 in each loop so when the loop finish it my other variable that I'm going to use for my other loop to show the characters would be representing only the characters and no the spaces.
Reply With Quote
  #9  
Old 01-30-2007
SkiesOfBordom's Avatar
Computer Techie
 
Join Date: Dec 2006
Location: NJ
Age: 22
Posts: 65
Rep Power: 4
SkiesOfBordom is on a distinguished road
Re: reverse count 'for' loops?

obviously there are more than 1 ways of doing things in VB. however, which of these ways will be most efficient for breaking down additive binary sequences such as 8212 and displayed by unchecking or checking items on a checkbox listbox?
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Thread and Post Count unclekyky Chit Chat and Hangout 1 08-17-2006 12:41 AM
How to count the newlines in a fetched source? Atolar JavaScript Coding 12 08-07-2006 12:38 AM
count how many times she hit her head gchick Chit Chat and Hangout 3 02-24-2006 10:28 PM
Web Count Tanner PHP Scripting 8 08-20-2005 08:30 PM
many wrong permiter errors demosthenes705 PHP Scripting 5 04-07-2005 03:33 PM