hi all,
i am having problems using the Trim() function in a program written in VB6. i'm getting my strings from reading a textfile line by line, but regardless of the trim function a couple of extra spaces are always included in the variable.
this is the code i use: -
Dim filepath As String
-
Dim FileNo As Long
-
Dim LineNo, i As Integer
-
Dim LineText As String
-
-
FileNo = FreeFile ' Get next available file number.
-
-
cdb.ShowOpen
-
filepath = cdb.FileName
-
-
Open filepath For Input Access Read Shared As #FileNo
-
Do Until EOF(FileNo) ' Repeat until end of file...
-
Line Input #FileNo, LineText ' Read a line from the file.
-
LineNo = LineNo + 1
-
-
txtFileName.Text = Trim(LineText) ' This line still leaves a couple of spaces at the end of the string in txtFileName.Text
-
-
DoEvents ' Allow Windows to handle other tasks.
-
Loop
-
Close #FileNo
-
why doesn't the Trim() function remove all tracing spaces?
3 8796
Hi,
Last Chars may be Chr(0) and not a Space. if they are Chr(0) then trim cannot remove those spaces. Instead use Replace Function : -
txtFileName.Text = Replace(Trim(LineText),Chr(0),"")
-
Regards
Veena
Hi,
Last Chars may be Chr(0) and not a Space. if they are Chr(0) then trim cannot remove those spaces. Instead use Replace Function : -
txtFileName.Text = Replace(Trim(LineText),Chr(0),"")
-
Regards
Veena
nope - didn't work. the strings are still trailed by spaces. could you please give me a simple function to split the string into a character array so i can check what characters they really are?
EDIT:
never mind - i took the last character, found out that it was chr(160) that i (also?) needed to replace, and when i did it worked. but the question remains... is there a better way to get the file extensions than using right(linetext,4)?
could you please give me a simple function to split the string into a character array so i can check what characters they really are?
Hi,
use this : -
Dim i As Integer
-
For i = 1 to Len(LineText)
-
Debug.Print Mid(LineText,i,1) & " Ascii = " & Asc(Mid(LineText,i,1))
-
Next
-
Regards
Veena
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mikael Hellström |
last post by:
Hi all,
i need to use the trim function trim("str","?")
My question are. How do i remove the "return sign" from a string??
Regards Mikael
|
by: Dominic |
last post by:
Here is the general problem:
Information is taken from a form (consisting of text boxes, drop down
lists et cetera) and submitted to an Access database. Before the data
is inserted into the...
|
by: SK |
last post by:
Trim function doesnt actually trim the spaces.Can anyone
help
|
by: Dave Bovey |
last post by:
I created a church database in Access 97 that contain the typical Name,
Address, and Phone Number information fields. I had a number of
different reports to print query data in different formats.
...
|
by: Sascha Herpers |
last post by:
Hi,
what is the difference between the trim function and the trim
String-member?
As far as I see it, both return the trimmed string and leave the
original string unaltered.
Is any of the two...
|
by: rkk |
last post by:
Hi,
I've written a small trim function to trim away the whitespaces in a
given string. It works well with solaris forte cc compiler, but on
mingw/cygwin gcc it isn't. Here is the code:
char...
|
by: jonosborne |
last post by:
Hi,
Im sure the TRIM function works fine, otherwise there would be thousands of people worldwide kicking up a right fuss. But for some reason it is not returning the desired result.
I have a...
|
by: ramaswamynanda |
last post by:
Hello All,
I have developed an application using Ms Access 2000. My client has Access 2003. I shipped him the code yesterday and he got an error hile running the application via the mdb file...
|
by: cmdolcet69 |
last post by:
I ahve the following code that need to trim off the last character
from a string
dim STR as string
If instr(STR <3 then
LTrim(STR)
THis code doesn;t work
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |