Trying to compare two strings (1 from a dropdown and the other from a list))

Hi everyone
I noticed that when Im choosing one of the first dropdown options it gives me the answer for another (that have almost the same string, for example: string1=“game”, string2=“game end” (its not really the string in the project but its kind of the same))

TESTING STUFF.xaml (9.2 KB)
Config - daniel.xlsx (8.4 KB)

in the config file I attached there is a table of 2 columns name and value, and i want to create the option to choose a name from the dropdown and get the number of it
my problem is that there is couple of names that have almost the same name and when i choose 1 of them (daniel - daniel end) it doesnt get the right one

thank u very much

1 Like

Hi
Do you mean like you want to set these Name column entries as drop down option to user
So that they can choose one from
With that chosen one we need to find the corresponding value from the Value column

Is it so

Cheers @dlichten

2 Likes

correct my good sir
and u can change the column how ever u want
BUT leave 2 entries with almost the same name (like daniel and daniel end, that have different numbers (in my project its almost the same number like 119 =119N but I dont think that it makes any difference))

cheers @Palaniyappan

Fine
Hope these steps would help you resolve this
—use a excel application scope and pass the file path as input and
Inside the scope use a read range activity and get the output with a variable of type datatable named dt
—now use a Input Dialog box activity with which we are going to choose the value from the column Name as a drop down
So for that we got a property called Options in that activity where we can pass the values to be displayed along the drop down as a ARRAY variable

So in that property mention this as expression
dt.AsEnumerable().Select(Function(a) a.Field(Of String)(“yourcolumnname”).ToString).ToArray()

Now this will display as a drop down form where we can select the value we want and get the output chosen as a variable named stroutput.

Then use a FOR EACH ROW activity and mention the input as dt
—inside the loop use a IF condition like this
row(0).ToString.Contains(stroutput.ToString)
If true it will go to Then part or to Else part
Inside that we can use a MESSAGE BOX activity and mention the input as row(1).ToString

Cheers @dlichten

I tried to change as u said
but it gave me couple of problems
can u make the changes in the file I uploaded and send it to me please?
because my dropdown have this line “String.Join(”, “, QueryTable.AsEnumerable().Select(Function(a) a.Field(of string)(“Name”)).ToArray())”
and if i will change it to what u said it will give problems in the dropdown

Cheers @Palaniyappan

Just mention this buddy in OPTIONS property of input dialog box activity

@dlichten

i wrote this in the IF and it didnt gave me answer: “row(1).ToString.Contains(QueryName.ToString)” (didnt went in the THEN section)
and in the message box I wrote: “row(1).ToString”

Aaha that was my mistake
Mention as row(0).ToString.Contains(QueryName.ToString) In IF condition

Cheers @dlichten

it worked half the times
i tried both the names with the almost same name and when I chose the “daniel end” it gave me the right answer but when I chose “daniel” it gave me both answers and then saved the wrong one
like what happen before…

Hi
If you want to check for the both then use in IF
row(0).ToString.Contains(QueryName.ToString)
Or
If you want to find the exact match then use in IF
row(0).ToString.Equals(QueryName.ToString)

Cheers @dlichten

ok now I really dont understand
I wrote the IF condition with EQUALS and it didnt work and even when it did work it gave me both answers…
IT WORKS PERFECTLY

so please explain what happen

2 Likes

Contains will search for match
But
Equals will search for exact value

That’s the difference buddy
Either of this would work for sure
But we need to choose based on the need

row(0).ToString.Trim.Contains(QueryName.ToString.Trim)
Or
If you want to find the exact match then use in IF
row(0).ToString.Trim.Equals(QueryName.ToString.Trim)

Cheers @dlichten

yeah that I know - AND IT WORKS PERFECTLY THANK U
but my problem was that I tried this already and it didnt work for me (dont know why)
and in the IF->THEN I wrote “row(“Value”).ToString”
and u said to use row(1) (why not 0?)

May be we would have missed any syntax buddy
No worries

And for this

We use index as 1 as the “value” column in the excel is the second column
Usually column index starts from 0 for the first column

Cheers @dlichten

thats what I thought but wasnt sure
(just to be sure. this: “row(“Value”).ToString” and this: “row(1).ToString” are actually the same?)
thank u very much for your time and patience
Cheers!!

1 Like

Yes buddy
One is with we call by its name and another is we call with its index position
Both are same
@dlichten

thank u very very very much!!!
@Palaniyappan

Cheers @dlichten

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.