hi there
i have this string -
dim str as string
-
-
str="1,2,3,4,"
i required this
can anyone help..!
8 11008
Heya, Kashan. Welcome to TSDN!
Please use CODE tags when posting source code:
[CODE=vb]
Visual Basic source code goes here.
[/CODE]
I'm going to go ahead and move this thread to the VB forum, where our resident Experts will be better able to help you out.
i required this
In what version of VB?
In what version of VB?
There is a substring method in VB.Net, or a mid function in VB.
Either one of these will allow you to pick out characters at set positions and allow you to delete them.
You could for example in VB. -
Dim str As String = "1,2,3,4,"
-
Dim str1 As String
-
-
Dim i As Integer = Len(str)
-
str1 = Mid(str, 1, i - 1)
-
This would pick out all characters except the last one which will be your comma, and store in str1.
Thanks JAmes
Thanks for that, James.
However, if you're going to post code, please try to ensure it's working code. Dim str As String = "1,2,3,4,"
...is VB.Net syntax and won't work in VB6 or earlier. In those versions you would need to do something like... - Dim str As String
-
str = "1,2,3,4,"
ahh i see, well thats a new 1 to me :P
I only use vb.net and didnt realise the small differences.
ahh i see, well thats a new 1 to me :P
I only use vb.net and didnt realise the small differences.
:)
That's probably just about the smallest of the differences. Some are huge.
I downloaded VB 2005 Express Edition weeks ago. But I haven't done anything with it yet because I just don't know where to start. There's so much to learn.
yes, maybe i should add that at home i use vb.net, and in work i downloaded the free vb 2005 express edition also, so im having to switch between the two! annoying!
although when i finally tried to use this i find little differences.
for example:
dim a as string = "123" works for both.
I understand this does'nt work for all versions of vb as you previously told me.
some versions require this???
dim a as string
a = "123"
I know this post may be pretty old but I found myself working in old VB6 code once more and had to create a couple of functions that removes characters from the start and end of a string so I wrote these functions. Maybe someone will find these useful if they're working with VB6 again. -
Public Function TrimEnd(ByVal someString As String, ByVal someChar As String) As String
-
-
On Error GoTo Err_Proc
-
someString = Trim(someString)
-
someChar = Trim(someChar)
-
-
If Len(someString) = 0 Then GoTo Exit_Proc
-
If Right(someString, Len(someChar)) <> someChar Then GoTo Exit_Proc
-
-
While Right(someString, Len(someChar)) = someChar
-
someString = Left(someString, Len(someString) - Len(someChar))
-
Wend
-
-
Exit_Proc:
-
TrimEnd = someString
-
Exit Function
-
-
Err_Proc:
-
-
'Err_Handler True, Err.Number, Err.Description, Erl, "Form1", "Function TrimEnd"
-
MsgBox Err.Description
-
Err.Clear
-
Resume Exit_Proc
-
-
End Function
-
-
Public Function TrimStart(ByVal someString As String, ByVal someChar As String) As String
-
-
On Error GoTo Err_Proc
-
someString = Trim(someString)
-
someChar = Trim(someChar)
-
-
If Len(someString) = 0 Then GoTo Exit_Proc
-
If Left(someString, Len(someChar)) <> someChar Then GoTo Exit_Proc
-
-
While Left(someString, Len(someChar)) = someChar
-
someString = Mid(someString, Len(someChar) + 1)
-
Wend
-
-
Exit_Proc:
-
TrimStart = someString
-
Exit Function
-
-
Err_Proc:
-
-
'Err_Handler True, Err.Number, Err.Description, Erl, "Form1", "Function TrimStart"
-
MsgBox Err.Description
-
Err.Clear
-
Resume Exit_Proc
-
End Function
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Lawson |
last post by:
I need to trim off trailing 0x00's from a binary string. Does anyone know how?
David
|
by: Alberto Vera |
last post by:
Hello:
I have the next structure:
How Can I make it using Python?
How Can I update the value of 6?
|
by: Andy Visniewski |
last post by:
I have three columns, RecordID, FirstName, and LastName, but somehow
through some program glitch, there is sometimes a trailing space in
the firstname and lastname columns, for example, a persons...
|
by: jalkadir |
last post by:
I am trying to find a way to remove the leading and tailing blanks from
a string.
What I have come up with is not doing the work as I expected; because
if the value I pass to the function is "...
|
by: Tammy |
last post by:
I am doing some genealogy research and I have discovered that there is
a lot of data available on the web in text format. The problem is
that the columns in the files are lined up by spaces. I'd...
|
by: bonehead |
last post by:
Greetings,
I'm using the DoCmd.TransferText method to export the results of a MS
Access query to a csv file. The csv will then be used to load an Oracle
table.
In other systems such as TOAD...
|
by: Smythe32 |
last post by:
Hi All,
I am trying to remove carriage returns from a text field via some code.
Here is an example of what I am up against.
The field streetname contains the little square box that I believe...
|
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= |
last post by:
Hello,
I've eliminated the bulk of code, this should be sufficient:
byte fromEncrypt;
string sDecryptedString;
//Read the data out of the crypto stream.
csDecrypt.Read(fromEncrypt, 0,...
|
by: Jan Sneeuwman |
last post by:
Hello,
I am working on a library in C++, and the library goes with a header file
with a trailing comma at the end of some enumeration. Like this:
enum Abc {
ENUM_ONE,
ENUM_TWO
ENUM_THREE,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |