Filter data table starts with integer value

I’m having an data table and I need to filter certain rows when the column(0) starts with 155 number.

I tried using filter data table and given the condition as starts with and value as “155” ( string ) and 155 ( int ), Neither of them works.

Before reading the data table from excel, I have changed the column type to number, still its not working

So used preserve type " on" , again its not working.

Noticed in one of the forum topic that starts with is function of string,

Could you please assist me on filtering the numeric value by starts with condition ?

Thanks

Hi @Fresher

Can you try this

image

dt_Data.AsEnumerable.Where(Function(r) r(0).ToString.Trim.StartsWith("155")).CopyToDataTable

Where dt_Data is your Data Table variable

@kumar.varun2 - Thanks you response, yes its working fine…
Is it ok to convert the numeric value to string and validate ( eg: starts with, contains. etc…)

Yes. For these type of comparison it is fine.

For arithmetic comparison the number should be in number format, like <,>,<=,>= etc.

@kumar.varun2 - Thank you !!

1 Like

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