Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi greetings, I need your help o

Status
Not open for further replies.

leskk

MIS
Dec 23, 2003
3
US
Hi greetings,

I need your help on this problem.
If i have 8 listbox each listbox have the same value
like this

value 1
value 2
value 3
value 4
value 5
value 6
value 7
value 8

If i selected value 1 on any listbox other listboxes cannot select this value 1 anymore, it will be pop up an alert box to warn that this value 1 is already been used by other listbox please choose another value. So this matter is to prevent duplicate selected value on all listboxes.

Your help is much appreciated. Thank you very much.

Rgds,
Les




 
This will do it for you.


'==========================================================================
'
' NAME: ArrayInput.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: ' DATE : 12/23/2003
'
' COMMENT: Comparing Array values for uniqueness
'
'==========================================================================

Dim Val, SubVal
Dim arrayValue
ReDim arrayValue(7)

For Val = 0 To 7
arrayValue(Val) = InputBox("Enter Value for Value " & Val, "Value " & Val)
For SubVal = 0 To (Val-1)
If arrayValue(Val) = arrayValue(SubVal)Then
arrayValue(Val)= InputBox("value already taken, enter another value " & Val, "Value " & Val)
End If
Next
results = results & "Value " & Val & " = " & arrayValue(Val) & vbCrLF
Next
MsgBox results
 
markdmac, your script don't work: you can enter the same value for all the 8 elements.
Here a modified working version:
Code:
Dim arrayValue(7)
For Val=0 To 7
  Do
    arrayValue(Val)=InputBox("Enter Value for Value "&Val,"Value "&Val)
    For SubVal=0 To (Val-1)
      If arrayValue(Val)=arrayValue(SubVal) Then Exit For
    Next
  Loop Until SubVal=Val
  results=results&"Value "&Val&" = "&arrayValue(Val)&vbCrLF
Next
MsgBox results

Hope This Help
PH.
 
Not sure what you are doing differently with my script. In my testing it prompts if the same value was entered and asks you to re-input a value.
 
markdmac, with your original script type 36 times the same value and look at the msgbox.
 
Thanks markdmac & PHV for your fast response. Actually i want is that there is no duplicate number occur on each listbox all is follow by priority number.

when i was selected value 1 for example:
on a) Holiday Package (Pakej Percutian), other listboxes if you choose the same value 1, it will warn and pop up the message box that this value is been used by other listbox. So it will block the user to select duplicate number.


Below is my test web form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top