i have a combination of lines like this:
X200876Y-140576
X220177Y12467
and i want to make this lines to be like this
X200.876 Y-140.576
X220.177 Y124.67
The program should works like this. It should read the line and it shoud add "." after 3 numbers from X and for Y also same thing After Y it should count 3 numbers and add [DOT] and avoid any other character after Y only count numbers.
Dim lines() As String = System.IO.File.ReadAllLines("C:\kaya.txt")
Dim sv As StreamWriter = File.CreateText("C:\\kaya.txt")
Dim line As String
For Each line In lines
Dim pos1 As Integer = line.LastIndexOf("X") + 1
Dim pos2 As Integer = line.LastIndexOf("Y") + 1
Dim leng As Integer = line.Length
Dim fstnum As String = line.Substring(pos1, pos2 - pos1 - 1)
Dim sndnum As String = line.Substring(pos2, leng - pos2)
If IsDigits(fstnum) Then
fstnum = "X" + fstnum.Insert(fstnum.Length - 3, ".") + " " '<--blank space added
Else
fstnum = "X" + fstnum + " " '<--blank space added
End If
If IsDigits(sndnum) Then
sndnum = "Y" + sndnum.Insert(sndnum.Length - 3, ".")
Else
sndnum = "Y" + sndnum
End If
editedLine = fstnum + sndnum
sv.WriteLine(editedline)
Next
sv.Close()
End Sub
Private Shared Function IsDigits(ByVal value As String) As Boolean
If String.IsNullOrEmpty(value) Then
Return False
End If
Dim regexp As Regex = New System.Text.RegularExpressions.Regex("^[0-9,-]*$")
Return regexp.Match(value).Success
Can any one help me to solve this problem
Thank you
!--removed tag-->
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).