Click here to Skip to main content
15,912,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a large string in VB .Net which i am reading from keycard.The information is in byte and i am converting the byte into string.
The string is as below 1 case:



Card type: Guest Card
Guest Card type: Enhanced Format
Operating Range: Floor
Building: 3
Floor: 7  8  9  10  11  12  
Accessible public door: 10  
Time Setting: NO
Need open public door: YES
Have Public Door Sector: NO
Open all public door: NO
Start Time: 2018-8-13 8:52:00
End Time: 2018-8-15 3:0:00
Area: 1
Building: 3
Floor: 10
Room: 1
Suite: 6  
Open Deadbolt: YES
Air-condition: NO
For Safe box: NO
Passage Mode: YES
Replacement: YES


The string is as Below in 2nd case:

Card type: Guest Card
Issued by: Software


What I have tried:

SO i want to retrieve below data from the string in case 1

Card Type	: Guest card
Tower		: 3	
Start Time	: 2018-8-13 8:52:00
End Time	: 2018-8-15 3:0:00
Floor		: 9
Room		: 3


Is it possible to get the required data from the large string
Posted
Updated 13-Aug-18 21:01pm
Comments
OriginalGriff 14-Aug-18 1:45am    
Probably - except you have two "Floor" code lines, and "9" appears to be wrong from what I can see.
What have you tried?
Where are you stuck?
What help do you need?
Member 13142345 14-Aug-18 2:00am    
Dim info as string
and cardinfo is byte type
and i am converting that byte into string and i will get the above string
info = System.Text.ASCIIEncoding.ASCII.GetString(CardInfo)

from that string i want to retrieve only cardtype,tower,starttime,endtime,floor and Room

1 solution

Do as below
C#
string[] lines = System.IO.File.ReadAllLines(filePath);
            List<string> str = new List<string>();
            for (int j = 0; j < lines.Length; j++)
            {

                var StdReportData = lines[j];
                switch (StdReportData.Split(':')[0].ToUpper())
                {
                    case "CARD TYPE":
                        str.Add(StdReportData);
                        break;
                    case "TOWER":
                        str.Add(StdReportData);
                        break;
                    case "START TIME":
                        str.Add(StdReportData);
                        break;
                    case "END TIME":
                        str.Add(StdReportData);
                        break;
                    case "FLOOR":
                        str.Add(StdReportData);
                        break;
                    case "ROOM":
                        str.Add(StdReportData);
                        break;
                }
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900