lets say i got a few string exp:

11111233NR+0001030 210NNR
99NR+001030 339NNE

each substring got dif meaning ....11111 for the ID , NNR for the location. etc

do you have any idea how to split them in each substring.

pls help me...

Dani AI

Generated

A concise, reliable workflow for these lines — inspired by , and — is to treat parsing as one of two problems: fixed-position (fields always at the same start/length) or pattern-based (fields identified by character classes or tokens). For batch processing, read the file line by line, validate lengths, Trim() fields, convert numbers with TryParse, and write parsed rows to a CSV or grid for inspection.

Example: safe fixed-position extraction in VB.NET (guard length before Substring):

Using sr As New System.IO.StreamReader("input.txt")
    Dim line As String = sr.ReadLine()
    While line IsNot Nothing
        If line.Trim().Length > 0 Then
            Dim id As String = If(line.Length >= 5, line.Substring(0,5).Trim(), line.Trim())
            Dim location As String = If(line.Length >= 3, line.Substring(line.Length - 3, 3).Trim(), String.Empty)
            Dim numericValue As Integer
            Integer.TryParse(If(line.Length >= 12, line.Substring(6,6).Trim(), String.Empty), numericValue)
            ' Emit CSV or insert into DataTable: id, numericValue, location
        End If
        line = sr.ReadLine()
    End While
End Using

When fields shift or lengths vary, use regular expressions to capture logical parts (for example: leading digits as ID and trailing letters as location). Example pattern usage:

Dim rx As New System.Text.RegularExpressions.Regex("^(\d+).*?([A-Z]{2,3})$")
Dim m = rx.Match(line)
If m.Success Then
    Dim id = m.Groups(1).Value
    Dim location = m.Groups(2).Value
End If

To execute a .bat and capture errors, run cmd with redirected output and inspect stdout/stderr for error tokens or nonzero exit codes. Common pitfalls: inconsistent encodings, trailing spaces, very short lines, and mixed delimiters — log unparsed lines for review and prefer defensive checks (length, TryParse) before Substring. This approach scales better than manual textbox splitting when processing many lines.

Recommended Answers

All 7 Replies

I'm so sorry I don't have a vb installed on my pc. I just reformated it.. try using this one as a partial code.

ID= left$(str,5)
str= mid(str,5)

hope it help.

though the problem here is that you the str is being crop continuously... try solving it.. you can do it..

this is if you dont have any delimeter, just wanted to seperated strings.

I'm so sorry I don't have a vb installed on my pc. I just reformated it.. try using this one as a partial code.

ID= left$(str,5)
str= mid(str,5)

hope it help.

though the problem here is that you the str is being crop continuously... try solving it.. you can do it..

this is if you dont have any delimeter, just wanted to seperated strings.

just a suggestion:
use another text box for another string you want to separate...

thnx ..... im happy to join this forum....

thnx ..... im happy to join this forum....

Does your problem resolved?

thnx ..... im happy to join this forum....

If you have any problem with string handling, remember it is not because of VB. I will tell you the clue if you are interested.

regards
AV Manoharan

then what are you waiting for ?

then what are you waiting for ?

im new to VB , now im in practical studies , so now i have to do this programming regarding open a batch file , read , and trace error as an output for the program.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.