Solved

# vb.net read and manipulate line

Posted on 2005-04-20
Medium Priority
200 Views
I need to know the best way to handle the below line

I have a line that looks like this in a database file

123+43444+122+1+5

I need the line to look like this

123434443333122199995

what i need is a way to look at any number inbetween lets say 43444, this line always has to have 9 digits, if it doesn't already then it need to add 3's until there is 9 digits same goes for the +1+ except it needs to always have 5 digits and if it doesn't add the 9's until it does another example

145+34+111+44+5

should look like
145343333333111449995

any ideas????
0
Question by:bear23
• 5
• 3

LVL 13

Accepted Solution

Corey Scheich earned 540 total points
ID: 13827871
Dim strTemp() as String
Dim OrigLine as string
Dim NewLine as string
Dim i as string

OrigLine = "123+43444+122+1+5"

strTemp = OrigLine.Split("+")

While strTemp(1).length < 9
strTemp(1) += "3"
end while

While strTemp(3).length < 5
strTemp(1) += "9"
end while

For each i in strtemp
NewLine += i
next

Msgbox (NewLine)
0

LVL 13

Expert Comment

ID: 13827878

While strTemp(3).length < 5
strTemp(1) += "9"   <---this is wrong
end while

Change it to

strTemp(3) += "9"
0

Author Comment

ID: 13836732
what if I need the 9's before

example

OrigLine = "123+43444+122+1+5"

123434443333122199995

would be

23434443333122999915

notice 9's before but still making it 5 characters???

0

LVL 13

Expert Comment

ID: 13836840
While strTemp(3).length < 5
strTemp(1) = "9" & strTemp(1)
end while

should do it
0

LVL 13

Expert Comment

ID: 13836852
There I go again copying my old mistake change
strTemp(1) to strTemp(3)
0

Author Comment

ID: 13837276
just curious what is a good way to clear the

strtemp()

0

Author Comment

ID: 13837281
like strtemp() = nothing????
0

LVL 13

Expert Comment

ID: 13837504
I think

StrTemp = nothing
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
###### Suggested Courses
Course of the Month16 days, 13 hours left to enroll