Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 6th, 2003, 12:18 PM
Registered User
 
Join Date: Aug 2003
Location: , Michigan, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default decode loop

hi all
this loop is supposed to count how many times the 2 numbers I select from my combo boxes appear together in the same column of my excel spread sheet but always gives "10" as the asnwer could somebody tell me where the mistake is??

thanks

lneilson
Dim intcount As Integer
Dim looper As Integer
Dim combo1number As Integer
Dim combo2number As Integer
Dim i As Integer
Dim exists1, exists2 As Boolean

'get the numbers you wish to search for
combo1number = 1
combo2number = 2

intcount = 0
For looper = 1 To Me.UsedRange.Columns.Count
'i.e loop through each column
exists1 = False
exists2 = False

For i = 1 To Me.UsedRange.Rows.Count
'search all rows
If Me.Range("A1").Offset(i - 1, looper - 1) = combo1number Then exists1 = True
If Me.Range("A1").Offset(i - 1, looper - 1) = combo2number Then exists2 = True
Next

'if both numbers appear in a column, count it
If exists1 And exists2 Then intcount = intcount + 1
Next
Text2.text= intcount

wb.Close

xlApp.Quit

Set ws = Nothing
Set wb = Nothing
Set xlApp = Nothing




Reply With Quote
  #2 (permalink)  
Old August 6th, 2003, 12:32 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

some things i see...
- where do you open the xls??
- why do you use me.. if you are opening a xls?? me is the current form...
- are you programing inside Excel?? then dont use offset, just set the range and use and i think you need formularr1p1 or something like that
- use a loop, not a for, so when you have 2 trues you just go out the loop
- the range is not column, rows??? i think you have misplaced the two of them...

HTH...


Gonzalo Bianchi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option for decode yogeshyl SQL Language 0 July 6th, 2008 11:52 PM
Decode function to display result in same row yogeshyl SQL Language 0 July 2nd, 2008 12:40 AM
[HOW TO] Decode / Decrypt Sha1 ??? oscarestany PHP How-To 1 August 6th, 2007 05:49 PM
Encode & Decode melvik SQL Server 2000 2 June 2nd, 2004 09:23 AM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM



All times are GMT -4. The time now is 05:45 AM.


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