Results 1 to 8 of 8

Thread: A problem I've encountered, anyone able to help?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    2

    Question

    I've been writing a pretty simple application that involves the user entering three numbers into a pair of text boxes (Three numbers each) and the result label changing according to what's written in there... I've tried both Select Case and If statements (An example of the code follows), but I get the same problem: On some (About 30%) combinations of numbers, instead of the result that's written for that combination I get a result for an entirely different combination! Here's an example of the code in Select Case and If:

    If TxtBoxone = 111 And TxtBoxtwo = 222 Then
    LblTheResult = "Whatever I want it to be"
    End If
    (More If code for other combinations)

    Select Case TxtBoxone And TxtBoxtwo
    Case 111 And 222: LblTheResult = "Whatever I want it to be"
    (More case code for other combinations)
    End Select

    I've tried converting the Text boxes to Integers, Doubles, Singles, Strings, Currencies... I've tried making LblTheResult the end result for both text boxes, and the numbers are right- but some of them still just call up the wrong words! I've had two IDENTICAL Case statements except for the second text box's entry and the entry in qoutation marks, and both of them made LblTheResult equal to the same thing.

    Any help would be appreciated, thanks.



  2. #2
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Post some code next time . try something like this with a select Case
    Code:
    Select Case Number
            Case Is = 222
                'It was 222
                    Do something here
    
            Case is = 333
                Something else here
            End Select
    Good Luck
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  3. #3
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Talking

    Hy post all your code it can't be that long. Let us have a look and we will see what we can do about your problem. We just need some code to work with.
    Sincerely,
    Chris


    Email: [email protected]
    AIM: KnightsOfTheMoon
    WebPage: http://kom.wicre.com
    ----------------
    VB6 Professional
    Abit ST6-RAID
    1000 MHZ
    512 MB PC133 Ram
    Nvidia GeForce 2 Ultra 64 MB
    Maxtor 81.9 Gig
    Win 98 SE

  4. #4
    Guest
    Griffin, PitbullCr, et al.....


    You're looking at a 1000 x 1000 array here, with 000, 111, ..., 999 being the diagonal. Unless you have some way of grouping the results (anything with box1=1?? is blue....), you are going to have to handle 1,000,000 different conditions.

    Sounds to me like a design problem. I'd need to know what the different boxes represent and what the different numbers inside the boxes imply.


    Good Luck
    DerFarm

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    2
    I did post an example of my code... And I only need to insert about 100 combinations and a Case Else for the rest. I'll try using the Do command thought, thanks.

    And each box has the first three digits of a Zip Code... does that help you any?

  6. #6
    Guest
    Griffin> Please provide an example of which numbers do not work. They seem to work fine for me.

  7. #7
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Originally posted by Griffin
    I did post an example of my code... And I only need to insert about 100 combinations and a Case Else for the rest. I'll try using the Do command thought, thanks.

    And each box has the first three digits of a Zip Code... does that help you any?
    I see that NOW and I read it before . I apologize I was under the influence of fibinootchi .

    Sorry ,

    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  8. #8
    Guest
    Actually, knowing that the terms are zip codes does make a difference.

    It is my impression that zip codes (generally speaking) do not cross political boundaries. Note the use of the operative term generally speaking.

    Assume your problem was to generate an approximate distance between two zipcodes. The first 2 digits can identify the state (35 and 36 for Alabama). Presumably, the 3rd digit would detail a specific region within the state (2 identifies the Birmingham area). Knowing the state and general region of the other zipcode would allow an easy lookup for the distance from Birmingham to ????.

    You could write a function which would return the state and region based on table lookups for each of the zips. Then you'd need a map/distance function to return the appropriate distance.

    You can define the localities by running a small program against the yellow pages for the various states. There should be several on the net. At the worst case, you can buy an old copy of the national phone registeries from some small company.


    Good Luck
    DerFarm

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