473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Unable to append string in VB

Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.

I have tried things like trim and using a string builder but it still
won't work.

Any advice would be greatly appreciated.

Cheers
Craig

Nov 21 '05 #1
8 4328
Craig,

It should be possible but withouth any code we cannot see anything, however
beside that the advices would go in this direcection.

Show otherwise some code as with the stringbuilder you are using as with a
normal classic string concatination it should go.

For Builing a SQL (select) string the SQLParameter class
http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps?

Cor
Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.

I have tried things like trim and using a string builder but it still
won't work.

Nov 21 '05 #2
* Two Beards <kr***********@gmail.com> scripsit:
Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.

I have tried things like trim and using a string builder but it still
won't work.


It's hard to give an answer without knowing the code. Make sure that
there are no 'ControlChar.NullChar' characters in your string. You can
use 'Strings.InStr' to detect the and then use 'Strings.Left' to cut out
the part in front of this characters.

--
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 #3
cheers, I did the following and found that the problem is control
characters. It seems that it returns a 30 char string every time. The
replace fixes the problem.

If album.EndsWith(ControlChars.NullChar) Then
album = album.Replace(ControlChars.NullChar, "")
MsgBox(album + "...test...")
End If
Thanks for your help.


Herfried K. Wagner [MVP] wrote:
* Two Beards <kr***********@gmail.com> scripsit:
Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.

I have tried things like trim and using a string builder but it still
won't work.

It's hard to give an answer without knowing the code. Make sure that
there are no 'ControlChar.NullChar' characters in your string. You can
use 'Strings.InStr' to detect the and then use 'Strings.Left' to cut out
the part in front of this characters.

Nov 21 '05 #4
You mentioned String.Left in your reply. I know that you can use code like a
= left(b,10) to get the 10 left most characters. However, the String class
member in the MSDN doesn't list a left or right method or property. Is
something like a = b.left(10) legal? I am trying to avoid the old Left and
right inherent in Visual Basic and stick to the string class but I't
cumbersome sometimes because using Left(a,10) where a is only "" gives a ""
result in visual basic but the string class a.substring(0,10) gives an error
when a="". By the way, I very much enjoy reading your replies to the news
group and have learned a lot from your replies to others as well as myself.
Thanks a lot.

"Herfried K. Wagner [MVP]" wrote:
* Two Beards <kr***********@gmail.com> scripsit:
Hi, I'm new to VB and .net so I may be mising something. I am trying to
dynamically build some SQL by appending to a string. Part of the SQL
comes from an mp3 id tag I have extracted from a file and stored in a
string. I can do all the normal stuff with the string like msgbox and I
can append it to another string but I cannot append to the end of it.

I have tried things like trim and using a string builder but it still
won't work.


It's hard to give an answer without knowing the code. Make sure that
there are no 'ControlChar.NullChar' characters in your string. You can
use 'Strings.InStr' to detect the and then use 'Strings.Left' to cut out
the part in front of this characters.

--
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 #5
On 2004-09-04, Dennis <De****@discussions.microsoft.com> wrote:
You mentioned String.Left in your reply. I know that you can use code like a
= left(b,10) to get the 10 left most characters. However, the String class
member in the MSDN doesn't list a left or right method or property. Is
something like a = b.left(10) legal?
No, there is no .Left method, it's a shared function in the Strings (not
String, re-read Herfried's post carefully) class in the VB library. In
other words,

a = Left(b,10)

as you suspect.
I am trying to avoid the old Left and
right inherent in Visual Basic and stick to the string class but I't
cumbersome sometimes because using Left(a,10) where a is only "" gives a ""
result in visual basic but the string class a.substring(0,10) gives an error
when a="".


True, but in this case it doesn't matter, since your index is the result
of a search and thus the string is guaranteed to be that length. BTW,
depending on your specific needs here, it may be easier and more robust
to simply replace NullChar with an empty string.
Nov 21 '05 #6
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit:
You mentioned String.Left in your reply. I know that you can use code like a
= left(b,10) to get the 10 left most characters. However, the String class
member in the MSDN doesn't list a left or right method or property. Is
something like a = b.left(10) legal?
No, it's not. You will have to use 'Substring' if you want to use a
method of your string object.
I am trying to avoid the old Left and right inherent in Visual Basic
and stick to the string class but I't cumbersome sometimes because using
Newer is not necessarily better.
Left(a,10) where a is only "" gives a "" result in visual basic but
the string class a.substring(0,10) gives an error when a="".
ACK. That's indeed very annoying. That's why I keep using the
functions provided in the 'Strings' module.
By the way, I very much enjoy reading your replies to the news
group and have learned a lot from your replies to others as well as myself.
Thanks a lot.


:-)

--
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 #7
The primary reason that I was trying to stick to the classes rather than
revert to Visual Basic Language was the possibility that Microsoft will, in
some future relese of VB.Net, eliminate the older Visual Basic functions such
as Left, Right, and Mid. Hey, thank for your info and opinion on this topic.

"Herfried K. Wagner [MVP]" wrote:
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit:
You mentioned String.Left in your reply. I know that you can use code like a
= left(b,10) to get the 10 left most characters. However, the String class
member in the MSDN doesn't list a left or right method or property. Is
something like a = b.left(10) legal?


No, it's not. You will have to use 'Substring' if you want to use a
method of your string object.
I am trying to avoid the old Left and right inherent in Visual Basic
and stick to the string class but I't cumbersome sometimes because using


Newer is not necessarily better.
Left(a,10) where a is only "" gives a "" result in visual basic but
the string class a.substring(0,10) gives an error when a="".


ACK. That's indeed very annoying. That's why I keep using the
functions provided in the 'Strings' module.
By the way, I very much enjoy reading your replies to the news
group and have learned a lot from your replies to others as well as myself.
Thanks a lot.


:-)

--
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 #8
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit:
The primary reason that I was trying to stick to the classes rather than
revert to Visual Basic Language was the possibility that Microsoft will, in
some future relese of VB.Net, eliminate the older Visual Basic functions such
as Left, Right, and Mid.


NO! That's definitely not true. Microsoft has /never/ said that these
functions will be removed and there is absolutely no reason to remove
them. They are part of VB.NET now and will stay part of VB.NET. There
will be many changes to VB.NET, but I assume that these functions
are/will be one of the most stable parts of the language.

--
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 #9

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

Similar topics

7
by: mattsniderppl | last post by:
Hi, i'm relatively new to C++ from java and am having a difficult time with pointers. I'm sure there is something simple that I am doing wrong, but I can't seem to write this in a way that doesn't...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
2
by: Bob Rock | last post by:
I already found an alternative way to accomplish this (using ReadBytes), still I'd like to understand why I'm getting and error reading a text file using the following method. The exception is...
0
by: Dakkar | last post by:
I have a code like this and when i execute my program im taking this error unable to enumarate the process module and here is my code public bool proccescheck()
2
by: ashish ranjan | last post by:
Hi there, I want to fetch data from database ,convert it in xml then send this xml from server.In Javascript file i am trying to parse it and bind these data to some control like textbox in...
7
by: ruvi | last post by:
I am getting runtime error 3021 - Either EOF or BOF is true or the current record has been deleted..... I have 2 combo boxes in a form- One for the client and the other for the project. When the...
10
by: HYRY | last post by:
I have the following questions, I am using Python 2.4.2 19167152 #1 11306608 #1 1. the address of a.append and list.append is different, can I get the address of...
3
by: lukethegooner | last post by:
I can't see the wood for the tree's here, I have some code set up to run through a bunch of delete queries, re-append fresh information to local DB tables then run a report. But in the code below...
4
by: mirajsen | last post by:
Hello, I have a data access page which is linked with a table. Users will enter the data through this particular DAP which is on a web server. I would like the DAP to capture and append the NT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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,...
0
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...
0
tracyyun
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...
0
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,...
0
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...

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.