Results 1 to 8 of 8

Thread: how to find pairs of n-variables

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    5

    how to find pairs of n-variables

    Hello everybody.!!

    I am very new to VB. I need to prepare an interface in VB6 where I have some variables like a1, a2, a3, a4...etc.
    i need the pairs of them like (a1,a2), (a1,a3),(a1,a4),(a2,a3),(a2,a4),(a3,a4).
    etc...
    and have to enter another 6 values for each pair manually.
    So i will be great full to u all if anybody suggest any idea........


    with regards
    Badwl
    NITW

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: how to find pairs of n-variables

    Thread moved from the 'VB.Net' (VB2002 and later) forum to the 'VB6 and Earlier' forum

  3. #3
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: how to find pairs of n-variables

    Not sure exactly what you're after...

    When you say "I need the pairs of them..." what do you mean?

    You want some text boxes in which to enter the numbers? Then do what with them?

  4. #4
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    Re: how to find pairs of n-variables

    How about an array of UDTs
    Private Type TPair
    V1 As Long
    V2 As Long
    End Type
    Private Pairs() As TPair
    Private PairCount As Long

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    5

    Re: how to find pairs of n-variables

    Quote Originally Posted by vbfbryce View Post
    Not sure exactly what you're after...

    When you say "I need the pairs of them..." what do you mean?

    You want some text boxes in which to enter the numbers? Then do what with them?
    actually i am not sure what exactly it say... but if u have variables like a1, a2, a3, a4,....etc. then how to find the pairs (a1,a2), (a1,a3), (a1,a4),(a2,a3),(a2,a4),(a3,a4)......and so on......which algorithm should I use for that?

    and after that one window(form) should come like
    ..........+X +Y +Y -X -Y -Z
    a1,a2...[ ] [ ] [ ] [ ] [ ] [ ]
    :
    :
    and so on.......

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: how to find pairs of n-variables

    I'm sorry but in order for us to help you you'll need to give a better explanation of what you want to do.

    What do you mean when you say "pairs"? You say you have variables named a1, a2, etc. Do you want to somehow find the variables themselves or do you want to find the values of the variables? In either case how do you decide if it's a "pair"?

    And the following I'm sorry to say makes no sense at all. What are the Xs, Ys and Zs? And what are the + and - signs? And the brackets?

    ..........+X +Y +Y -X -Y -Z
    a1,a2...[ ] [ ] [ ] [ ] [ ] [ ]
    :
    :

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: how to find pairs of n-variables

    If your application has a database engine then you can let the database ngine do the cartesian join rather than worrying about algorithm.

    SELECT a.column_value, b.column_value
    FROM your_table a
    , your_table b
    WHERE b.seq_no > a.seq_no -- this eliminates pairs like (a1,a1) and duplicates, e.g. (a1, a2) and (a2, a1), from result since you will be joining current record only to records that come after it

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    5

    Re: how to find pairs of n-variables

    Quote Originally Posted by leinad31 View Post
    If your application has a database engine then you can let the database ngine do the cartesian join rather than worrying about algorithm.

    SELECT a.column_value, b.column_value
    FROM your_table a
    , your_table b
    WHERE b.seq_no > a.seq_no -- this eliminates pairs like (a1,a1) and duplicates, e.g. (a1, a2) and (a2, a1), from result since you will be joining current record only to records that come after it
    leinad31 Sir ,
    Thank you.....very much ... It will be very much helpful to my project works...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width