Prompt or message box if specific values not found

Prompt or message box if specific values not found

JohnBoySarcia
Advocate Advocate
318 Views
6 Replies
Message 1 of 7

Prompt or message box if specific values not found

JohnBoySarcia
Advocate
Advocate

Hi, good day.

 

May I kindly ask if there's an ilogic rule to trap if the values don't exist on the given table.

For example:

oList.Add("6" & "|" & "XS" & "|" & 168.275 & "|" & 10.973 & "|" & 146.329)

oList.Add("6" & "|" & "120" & "|" & 168.275 & "|" & 14.275 & "|" & 139.725)

 

If my oValues (0) = "6" and my oValues (1) = "100" then there should be an error, alert or messagebox

Is this possible?

 

Thanks

0 Likes
Accepted solutions (1)
319 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

Hi @JohnBoySarcia 

Can you confirm what the purpose of the "|" is in the string array? Is this a simple list of string or are you concatenating the whole string together. Can you supply an image of what it looks like displayed to the user? 

Are you using a list (Of String) 

 

If so you can use a

If oList.Contains("100") then

....

End If

 

Can you supply more of the code where you are setting the list object and what value your trying to detect. Will it always be 100? 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 7

JohnBoySarcia
Advocate
Advocate

This is a string array to separate values like a column

For Each oRow In oList
    oValues = Split(oRow, "|")	

 

0 Likes
Message 4 of 7

A.Acheson
Mentor
Mentor

Is a method for checking value in a list of string instead of using string array and splitting the string.. Can you share the whole sample your working with and put in the logic that your looking to achieve even in words. It is hard to figure out what your looking to achieve.

Dim list As New List(Of String)
list.AddRange({"er", "ert", "tyu" })

d0 = InputListBox("Prompt", list, d0, Title := "Title", ListName := "List")

If Not list.Contains("123") Then
	MessageBox.Show("123 doesn't exist", "Title")
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 7

JohnBoySarcia
Advocate
Advocate

Dim psize As String = Size

Dim psch As String = Schedule

oList.Add("6" & "|" & "XS" & "|" & 168.275 & "|" & 10.973 & "|" & 146.329)

oList.Add("6" & "|" & "120" & "|" & 168.275 & "|" & 14.275 & "|" & 139.725)

Dim oList As New ArrayList

For each oRow In oList

oValues = Split (oRow, "|")

If oValues(0) = psize AndAlso oValues (1) = psch Then

d0 = oValues(2)

d1 = oValues(3)

d2 = oValues (4)

Exit For

End If

 

'This is the simplified program. Now if my size = 6 and sch = 100 as actual selected values, then it should give a message that it was not on the list. Currently it just do nothing and retain the last working values

0 Likes
Message 6 of 7

A.Acheson
Mentor
Mentor
Accepted solution

 

I couldn't find any errors. Here is a method with boolean check.

Dim psize As String = "6"

Dim psch As String = "XS"

Dim oList As New ArrayList

oList.Add("6" & "|" & "XS" & "|" & 168.275 & "|" & 10.973 & "|" & 146.329)

oList.Add("3" & "|" & "120" & "|" & 168.275 & "|" & 14.275 & "|" & 139.725)

d0 = InputListBox("Prompt", oList, d0, Title := "Title", ListName := "List")

Dim check As Boolean = False


For Each oRow As String In oList
	
	oValues = Split (oRow, "|")
	Logger.Info(oValues(0) & " - " & oValues(1))
	
	If oValues(0) = psize AndAlso oValues(1) = psch Then
		
		check = True
		
		MessageBox.Show("Entered Size & Sch found", "Title")
		
		d0 = oValues(2)

		d1 = oValues(3)

		d2 = oValues(4)
		
		Exit For
	End If
Next

If check = False Then
	MessageBox.Show("Entered Size & Sch not found", "Title")
End If

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 7

JohnBoySarcia
Advocate
Advocate

Although I need to tweak something, it works. Thank you very much for your help

0 Likes