Programming question

Techno

Golden Member
Oct 9, 1999
1,063
0
0
Hello,

I have a program that reads a file and then imports the data in this file to a sql server. The problem is, the file has spaces in certain fields.. like for example we have an account number that is DDA\827364556 yet in the file, sometimes it comes in as DDA \827364556 or in some cases it says DDA\827 364556. So the spaces can be just about anywhere and its only in this one field in the file. Never anywhere else. in Visual Basic 6, how can i get it to before sending the field to the table in the database, it looks for spaces and then deletes it and left justifies everything?

Thanks!
T.
 

edmicman

Golden Member
May 30, 2001
1,682
0
0
off the top of my head....but isn't there a replace() function or something? like you'd do replace(original_string, string_you_want_to_search_for, string_to_replace_with)? then do something like replace(string, ' ', '')? I'm not sure on the syntax, though. heh i'm a lot of help, huh. I think the TRIM() function would get rid of any leading or trailing whitespace, too. msdn.microsoft.com is a good resource, too. good luck!

edit:
msdn's site apparently is crap now...i haven't done vb6 programming in awhile and i can't seem to find the right way to search for vb6 string functions. i did find this on google:

http://www.officecomputertraining.com/vbtutorial/tutpages/page19.asp

I think all you need to do, is something like TRIM(REPLACE(stringvar, " ", ""))

Note, in between the quotes is a single space, and then NO space. Good luck!
 

ArjSiv

Member
Apr 6, 2005
37
0
0
This is why 99% of developers dread visual basic

Any sort of string manipulation in VB is difficult ( or at least grossly inefficient ).

You can try iterating through each character in the string and then copying it over if and only if it's not a space. However I remember fighting with VB a few years back and I wouldn't figure how to access a specific character in a string without having to do something like right( length - offset -1, left( offset, string ) ).

Personally I'd never use VB in the first place, but I do recall it's easy to call another application from a VB app, you might want to write a simple perl script that will parse out the spaces and maybe even just pipe the output to the VB application as standard input.
 

cappsa

Senior member
Sep 14, 2000
235
0
0
Just like edmicman said. One line. No need to reinvent the wheel when VB's got you covered.

str = Replace(str," ", "")

 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |