Results 1 to 7 of 7

Thread: Help needed: Auto Addition of Case Commands

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sinagpore
    Posts
    42

    Question Help needed: Auto Addition of Case Commands

    I'm new to VB6 so I'm wondering whether VB6 has the ability to add Case commands automatically. This is what I wish to do:

    A form has 2 Textfields and 1 Button :
    txtLower.Text = Lower Threshold of numbers
    txtUpper.Text = Upper Threshold of numbers
    cmdOk = Confirmation button

    A user key in 2 numbers (lower threshold and upper threshold respectively). When he is done with the filling of the threshold, he will click cmdOk and I wish codes will carry out adding a new case command with respect to the threshold user keyed in . Can this be done?

    Select case check
    case txtLower.Text To txtUper.Text
    .
    .
    .
    .
    and so on

    Thanks for any advise, ideas, teachings and source codes.
    Last edited by Warren Ang; Sep 7th, 2004 at 03:46 AM.

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424
    Auto Addition of Case Commands is not possible and don't think it is possible any other language. This is not the way how programming languages work.

    Can u explain bit more. i don't get it.

  3. #3
    New Member
    Join Date
    Mar 2004
    Posts
    15
    No, the code must be there from the start.

    What you can do is to do several test's in a loop for each condition the user wants.


    VB Code:
    1. private type udtThreshold
    2.    Lower as integer
    3.    Upper as integer
    4. end type
    5.  
    6. Dim threshold() as udtThreshold
    7. dim i as integer
    8.  
    9. redim threshold(10)
    10. 'Threshold array hold the saved values to check.
    11.  
    12. For i = lbound(threshold) to ubound(threshold)
    13.   if inputvalue >= threshold(i).lower and inputvalue<= threshold(i).upper then
    14.  'Do your code here
    15.  
    16. end if
    17. next i

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sinagpore
    Posts
    42

    Reply to Deepak

    Hi, Deepak. I can explain more to you.

    I have a form that allows user to key in Product_ID (001, 450, 079...). Lets say he wish to key in Product_ID (001 to 009), then this will means 001 = lower limit = txtLower.text and 009 = upper limit = txtUpper.text.

    Then when he has done, he clicked cmdOK. I wish from here the sub cmdOK_Click() will allow the addition of Case commands to add the new generated limit control, which is

    VB Code:
    1. case 001 to 009

    Then i will clear txtLower.Text and txtUpper.Text textfields and continue allow the user to add more new limits.

    I wonder is there any ways to do this request of mine. Help or tips are greatly appreciated and learned. Thank you.

  5. #5
    New Member
    Join Date
    Mar 2004
    Posts
    15
    You can't do it! End of story....

    But, what do you want to do? You want to check for lower/upper value and then do what? Call a sub, calc new values?

    Plz tell us how this check and select case works.

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sinagpore
    Posts
    42
    Ok I shall reveal all my things. 1st, the lower and upper limit form is to allow users to key in product ids. The real situation of the tags id is very complex. (example : 00090000673A5E9A). Human errors will occur and this will result in terrible wrong cataloging the product supplies. Like tagging a tag number of mentos to a snooker table. This will generate losses to the company.

    I need to allow the continuous addition of the limits checking so when i do a check using RF or watever detecter, i can use the case method to allow me to sound an alarm or pop up an error message, telling me that wrong tagging of products are detected.

    I know how to do all these. But I'm basing my way of thinking in terms of Case/Else. And I do think I cant add new Case commands to check the limits whenever i have new stocks. Sad...T_T

  7. #7
    New Member
    Join Date
    Mar 2004
    Posts
    15
    This is your 'Select case' check.

    To add new limits just write this to cmdOk

    (General declaration)
    VB Code:
    1. private type udtThreshold
    2.    Lower as integer
    3.    Upper as integer
    4. end type
    5.  
    6. Dim threshold() as udtThreshold
    7.  
    8. sub SubToCheckValues()
    9.  
    10. dim i as integer
    11.  
    12. For i = lbound(threshold) to ubound(threshold)
    13.   if inputvalue >= threshold(i).lower and inputvalue<= threshold(i).upper then
    14.  'Do your code here
    15.   MsgBox "Value is within limits"
    16.     end if
    17.   next i
    18. End Sub
    19.  
    20.  
    21. form_load
    22.  
    23. redim threshold()
    24. 'Threshold array hold the saved values to check.
    25.  
    26. 'You must add code to save this array at the end of program. And read it back in, when you start the program.
    27.  
    28.  
    29. end sub
    30.  
    31.  
    32. sub cmdOk_Click()
    33.  
    34.    redim preserve threshold(ubound(threshold)+1)
    35.    threshold(ubound(threshold)).lower = CInt( txtLower.Text)
    36.    threshold(ubound(threshold)).upper = CInt(txtUpper.Text )
    37. end sub

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