• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

visual basic editting a line from database

I have a record like this


This is a great one                       03245445Might even go home              545455


this is one record that looks exactly like the real thing

the first bit is 19 char long = This is a great one  
2nd is 9 = 03245445
3rd is 19 = Might even go home
4th is 6 = 545455


what i need to do is final result

This is a great one:idtnum-03245445:
new record:
STATEMENTS-ID-Might even go home:zip-545455

now i was think of first breaking each part up and storing the value to a variable then doing a replace for additional info and then making a variable that pieces it all together. Is that the best solution.
ex.

firstpart = left$(record.fields, 9)
etc.

the char lengths will always be the same the words will not except for the ones that I am manually adding.

this is in visual basic 6.
0
peanut1010
Asked:
peanut1010
1 Solution
 
JohnK813Commented:
"now i was think of first breaking each part up and storing the value to a variable then doing a replace for additional info and then making a variable that pieces it all together. Is that the best solution."

That's probably the way I'd approach this.  Was this a question of opinion or do you need help on this?
0
 
PhoenixricCommented:
HI!
If you're trying to edit a line from a database, and using this function left$(record.fields, 9) etc. , I guess using left$() alone will not work unless you used Mid(), but I assumed that it is in the etc. part :-) Anyway, you do exactly what is right to achieved the output you need. . And I might as well do the same method as you did for some advantages such as, you have breakdown particular piece on the record and its now more easy to identify for modification in the future.
Also,
You might do it using one variable with just a little knowledge in concatenation.
e.g.
Dim cWholePart as string

cWholepart = left(records.fields,19) & ":idtnum-" & Mid(records.fields,20,9) & ":new record: STATEMENTS-ID-" & Mid(records.fields,29,19) & ":zip-" & Mid(records.fields,48,6)
'Somewhat the last update will be like this
records.fields.edit
records.fields=cWholepart
records.fields.update

Hope this one helps. Gudluck.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now