473,671 Members | 2,341 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string problem - please help

hi,

i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?

Thanks.
T :-)

Nov 21 '05 #1
10 1044
maybe something like this:

dim mystring as string = ""
for i=1 to 3
if len(mystring) = 0 then
mystring = Cstr(i)
else
mystring = mystring & ", " & CStr(i)
end if
next i

this will give you 1,2,3

hope this helps..
Imran.

"Tiraman :-)" <ti*****@netvis ion.net.il> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl...
hi,

i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?

Thanks.
T :-)


Nov 21 '05 #2
Here's one way. Note that the function doesn't do any checking or trimming,
so it will happily append empty strings or strings containing nothing but
white space. Also note that if you're going to do very many of these string
concatenations, you should use a StringBuilder instead.

Function AppendCommaDeli mitedValue(ByVa l s As String, ByVal appendValue
As String) As String
If s.Length = 0 Then
s = appendValue
Else
s = s & "," & appendValue
End If
Return s
End Function
"Tiraman :-)" <ti*****@netvis ion.net.il> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl...
hi,

i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?

Thanks.
T :-)


Nov 21 '05 #3
* "Tiraman :-\)" <ti*****@netvis ion.net.il> scripsit:
i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?


\\\
Dim MyString As String = OtherString
For i = 2 to 3
MyString &= ","
MyString &= OtherString
Next i
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Tiraman,
A couple of other possiblities:
Dim mystring as string = "" Dim delim as string for i=1 to 3
mystring = mystring & delim & otherstring delim = "," next i

Dim strings(2) As String
strings(0) = otherstring1
strings(1) = otherstring2
strings(2) = otherstring3

mystring = String.Join("," , strings)

I prefer String.Join when my strings are already in an array, other wise I
use the first one.

Hope this helps
Jay

"Tiraman :-)" <ti*****@netvis ion.net.il> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl... hi,

i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?

Thanks.
T :-)


Nov 21 '05 #5
Hi Tiraman,

Can you learn me how you do that?

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this
"a,b,c,"


Cor
Nov 21 '05 #6
hi every one,

thanks for the examples.
all of the examples are good.

bye and thanks again :-)
T :-)

"Tiraman :-)" <ti*****@netvis ion.net.il> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl...
hi,

i have a little problem to concat a string with some "," sign.

this is my code:

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this

"a,b,c,"

and with numbers i m getting this result

",1,2,3"

how can i make it "a,b,c" and "1,2,3" ?

Thanks.
T :-)


Nov 21 '05 #7
Hi Cor,

Learn you what ?

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uu******** ******@TK2MSFTN GP09.phx.gbl...
Hi Tiraman,

Can you learn me how you do that?

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this
"a,b,c,"


Cor

Nov 21 '05 #8
>
Learn you what ?


Get that a,b,c result with that code.

I was searching how you did that, however without any result.
When I use the codes samples others provided to you it is of course no
problem even not doing it like this (I thought the sample Herfried showed
you)

\\\
mystring = "a"
for i = 2 to 3
mystring = "," & chrw(i+96)
next
///
However the way you did it I could not succeed.

:-)

Cor

Can you learn me how you do that?

Dim mystring as string = ""
for i=1 to 3
mystring = mystring & "," & otherstring
next i

and i m getting the result like this
"a,b,c,"


Nov 21 '05 #9
hi,
if i understand you then my code didn't get me a good result and bcz of that
i asked you guys for help.
bye

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uz******** ******@TK2MSFTN GP10.phx.gbl...

Learn you what ?


Get that a,b,c result with that code.

I was searching how you did that, however without any result.
When I use the codes samples others provided to you it is of course no
problem even not doing it like this (I thought the sample Herfried showed
you)

\\\
mystring = "a"
for i = 2 to 3
mystring = "," & chrw(i+96)
next
///
However the way you did it I could not succeed.

:-)

Cor

Can you learn me how you do that?
>
> Dim mystring as string = ""
> for i=1 to 3
> mystring = mystring & "," & otherstring
> next i
>
>and i m getting the result like this
> "a,b,c,"


Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
9580
by: Ahmad A. Rahman | last post by:
Hi All, I have a string as and I want to split the string, which will turn into an array of: Arr = "1"; Arr = "two"; Arr = "three"; Arr = "fo""ur"; Arr = "fi,ve";
6
43172
by: LCD | last post by:
This a rather simple question for all you studs out there! Please help me with this. I have a string = "Please help me", and I want to convert this into it's hex equivalent. How do I do it, I have trying for a couple hours and can't seem to get my head straight arount this whole conversion things. TIA, LCD
5
2404
by: geotso | last post by:
Here is the scenario: 1. I have a table (tblCalendar) with the following fields: caldID caldDate caldTitle caldInfo nWinW nWinH
8
8316
by: vidya.bhagwath | last post by:
Hello Experts, I am using std::string object as a member variable in one of the my class. The same class member function operates on the std::string object and it appends some string to that object. My sample code is as follows. ..h file content---------- #include <stdio.h>
9
3871
by: MikeB | last post by:
Hi, I'd appreciate some help, please. I'm writing a VS2005 VB project for school and one of the requirements is that every screen should have a "Help" button. I could do it by writing a clumsy case statement like this: sub showHelp(byval frm as String) Select Case (frm) Case "Form1" dim help as new Form1
8
4990
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to string and print it. but i want to use the String.Format() method if possible to do it.
11
5044
by: Sudzzz | last post by:
Hi, I'm trying to convert a string something like this "{201,23,240,56,23,45,34,23}" into an array in C++ Please help. Thanks, Sudzzz
6
1611
by: djm | last post by:
hello everyone, im doing a c++ coursework which consists linked lists and use of classes. but im getting some compilation errors. can some please help me out. //this is the header file Definition.h #ifndef DEFINTION_H #define DEFINITON_H #include <string> using namespace std;
8
6329
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource. Just to get it to work, I hard-coded the username and password of a SQL Server account in the connectionstring in web.config. Once I confirmed that this worked on the web server, I wanted to remove the hard-coded password from web.config, so I...
5
5015
by: mvmashraf | last post by:
Hi to all.... I have spent some time browsing for a solution to the following error but have unfortunatly not found any solution yet ,Please any help would be much appreciated.... ------------------------------------------------------------------------------------------------- This is the full error description... "Error Message :Invalid character in a Base-64 string." Error Source :mscorlib Error Stack Trace : ...
0
8397
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8919
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7439
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6230
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2813
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.