|
-
Sep 7th, 2004, 03:41 AM
#1
Thread Starter
Member
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.
-
Sep 7th, 2004, 04:03 AM
#2
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.
-
Sep 7th, 2004, 04:06 AM
#3
New Member
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:
private type udtThreshold
Lower as integer
Upper as integer
end type
Dim threshold() as udtThreshold
dim i as integer
redim threshold(10)
'Threshold array hold the saved values to check.
For i = lbound(threshold) to ubound(threshold)
if inputvalue >= threshold(i).lower and inputvalue<= threshold(i).upper then
'Do your code here
end if
next i
-
Sep 7th, 2004, 08:35 AM
#4
Thread Starter
Member
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
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.
-
Sep 7th, 2004, 08:41 AM
#5
New Member
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.
-
Sep 7th, 2004, 09:11 AM
#6
Thread Starter
Member
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
-
Sep 7th, 2004, 09:42 AM
#7
New Member
This is your 'Select case' check.
To add new limits just write this to cmdOk
(General declaration)
VB Code:
private type udtThreshold
Lower as integer
Upper as integer
end type
Dim threshold() as udtThreshold
sub SubToCheckValues()
dim i as integer
For i = lbound(threshold) to ubound(threshold)
if inputvalue >= threshold(i).lower and inputvalue<= threshold(i).upper then
'Do your code here
MsgBox "Value is within limits"
end if
next i
End Sub
form_load
redim threshold()
'Threshold array hold the saved values to check.
'You must add code to save this array at the end of program. And read it back in, when you start the program.
end sub
sub cmdOk_Click()
redim preserve threshold(ubound(threshold)+1)
threshold(ubound(threshold)).lower = CInt( txtLower.Text)
threshold(ubound(threshold)).upper = CInt(txtUpper.Text )
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|