Getting records of base ranges (will be char, will be int)

I have a different scenario. The name column is of type varchar. I want to get records based on numbers: For example: if I enter a range of records from A to Z, I need to get records between room names A, B, C ... Z

If I enter the range of numbers from R1 to R30, you get all entries between R1 and R30

How can i do this

+3


source to share


1 answer


See this answer:

As an operator in Entity Framework?



You should use this method to narrow down your writing results to at least the letter component in your number. From there, a little VB will take you the rest of the way.

'I assume:
'results() is a string array of room numbers formatted like "R1" or "R30"
'rangeStart and rangeEnd are corresponding integers, e.g. 1 and 30

For Each roomName As String In results
    Dim roomNum As Integer = CInt(Mid(roomName, 2))
        If roomNum > rangeStart And roomNum < rangeEnd Then
            'Your code here
        End If
Next room

      

+1


source







All Articles