String Concatenation: Using += Versus &=?
Sep 13, 2010
Possible Duplicate: The difference between + and & for joining strings in VB.Net.In VB.NET you can use either += or &= to concatenante a string (ignoring using a StringBuilder for this question -- this is directed at a very simple concatenation).
View 2 Replies
ADVERTISEMENT
Apr 12, 2012
I have a simple question about string concatenation. Following is the code. I want to ask why s6 = "abcde" and not "akcde"? I have change the s2 value to "k".
Public Class Form1
Public s1 As String = "a"
Public s2 As String = "b"
[Code]....
View 5 Replies
May 15, 2008
I've spent the last 3 hours trying to figure out why this string won't concatenate.
The function takes in a mapped drive letter and creates a UNC path and returns it.
Any thoughts welcome:
View 9 Replies
Oct 18, 2011
In VB.net, I tested concatenating 100k strings and found out one thread alone did it in 23 milliseconds. Two threads (each concatenating 50k) then joining the two at the end took 30 milliseconds. Performance wise, it didn't seem beneficial to utilize multiple threads when dealing with only 100k concatenations. Then I tried 3 million string concatenations and two threads each handling 1.5MM always demolished one thread handling all 3 million. I imagine at some point using 3 threads becomes beneficial, then 4, and so on. Is there a more efficient way to concatenate millions of strings in .NET?
fyi, this is the code I wrote:
Imports System.Text
Imports System.Threading
Imports System.IO
[code]....
View 2 Replies
Nov 9, 2011
The below program throws a runtime error (invalid conversion from double) because there is [code]It compiles fine, but when the program is run, it throws a runtime error.Is this a compiler bug? Shouldn't it stop me with a compiler error, like invalid syntax ?
View 2 Replies
Nov 24, 2010
I am facing a really very interesting problem with string.
My code is
[Code]....
But when I comment those lines (which are uncommented in code above) its working fine.
I am taking value in filepath variable from file dialog's FileName property.
EDIT: I have also compared the values of variable stropt and strwithpara with "IF" condition and found those are same.
View 1 Replies
Jun 14, 2012
I'm trying to concatenate two properties into one string like so:
public class thing
public property word() as string()
public property count() as integer()
[Code]....
This is what I want, but it doesn't help that its in the debug output...I need to put it into a single string. I've tried using a_thing.count(i).tostring, but it doesnt work. If I look at the arrays individually, they have exactly the contents I want. But I can't concatenate them. Does it have something to do with suppressing the new line that debug.writeline usually creates?
View 1 Replies
Jul 30, 2011
The intent of the code is to open an xls file -minimize it , search for keywords . there are columns like test case name ,priority(simple ,medium and high) with associated keywords.If keywords are found, it shld save the test case name - Priority in a text box. When i run this code i am getting err in
[Code]....
View 1 Replies
Mar 29, 2011
I've got a small app which I use to start a 3rd party application. When run from a shortcut the VB app starts the 3rd party app to and when loaded it displays its own file/folder interface, the VB app the closes itself. However, if you open a file in explorer associated with the 3rd party app, the 3rd party application loads and opens the file itself and not the file/open interface.
Uh OK, so what's the problem??The issue is I have changed the file extension associated with the 3rd party app to now use my VB app. I can successfully open files with the app from explorer if there are no spaces in the file or folder path however if there are, the 3rd party app opens and displays a File not found error message and gives the path up to the point where the space then follows.The relevant snippets of code from the app relating to the issue is below, specifically Dim Arguments variable where I am not quite sure how my string cocantenation should be to deal with the value of the variable 'Filename' which may or may not contain spaces.
[code]...
View 26 Replies
Jan 16, 2009
just want to know what is the difference between these date values?Once some one told me that its difference is server date and client date but not sure which one he meant.Below is 3 type of date currently I'm using and don't know what is the difference between them.
DateTime.Now is from System.DateTime.Now
Now is from Microsoft.VisualBasic.DateAndTime
Today.date is also from System.DateTime
View 4 Replies
Feb 10, 2010
I have 8 sentences, such as:
"Hello and we Hope you enjoy our service<100>"
"Good Morning Mr something nice to see you <200>"
"Good Evening Welcome to this domain <300>" etc etc
(The actual requirement is long sentence about 10 or 15 word and 8 different sentences.) I want to check which on is the response from the xmlhttp, I am doing that by searching the response if it contain <100> or <200> or <300> and depends on that I want to display "Login Faild", "Login success", "Server Down" etc.. what I mean, I have a place for 4 words in my listview and i don't want to put the complete response that came from the server, my question is, how to do it? I had tried to use Select Case in this way, it did not worked.
Select Case MyResponse
Case MyResponse.Contain("<100>")
MyResult = "Login Failed"
[code]....
View 5 Replies
Feb 4, 2010
The following output produces a string with no closing xml tag. m_rFlight.Layout = m_rFlight.Layout + "<G3Grid:Spots>" + Me.gvwSpots.LayoutToString() + "</G3Grid:Spots>"
This following code works correctly
m_rFlight.Layout = m_rFlight.Layout + "<G3Grid:Spots>" + Me.gvwSpots.LayoutToString()
m_rFlight.Layout = m_rFlight.Layout + "</G3Grid:Spots>" 'add closing tag
What's going on here, what's the reason the first example isnt working and the second is?
The gvwSpots.LayoutToString() function returns a string.
View 3 Replies
Jan 12, 2011
Is there any difference between & and + operators while concatenating string?if yes, then what is difference? And if No, then why below code generating exception?
Example:
Dim s, s1, t As String
Dim i As Integer
s1 = "Hello"
[code]....
View 6 Replies
May 8, 2010
I am wondering how to concatenate a string and an integer to form a button name.eg, ("button" & x) where x is an integer to form button1, button2, etc so i can change the backcolor of the buttons.
View 2 Replies
Jun 1, 2010
i am currently working on a small project, but to be honest i am quite new to VB i am trying to run this code:
For i As Integer = 1 To box_select_solp
cell_solp_text(i).Controls.Add(New LiteralControl("SOLP" & i & "#: "))
Next i
View 1 Replies
Aug 20, 2011
I'm trying to compose a String from multiple Strings, where some of the Strings may be in Arabic letters, the problem is that when I concatenate them, their order is being messed !!
For example, I have the following Strings:
Ref1
مسكه
2
Left
I want to concatenate them with the same previous order seperated by "-", but instead I get Ref1-مسكه-2-Left, as you can see, 2 is written before مسكه Does anyone know how to fix this problem, because it's really important in my case to have the exact same order, and I don't know where or when I might have these arabic strings, because it's being entered by User.
View 3 Replies
Nov 10, 2011
I have a windows form having combobox and textbox controls.. I have to generate a part number, consisting of combobox and textbox values included.. I can explain in detail.. This is the code i have used to define a variable "type"..
[Code]...
View 5 Replies
Apr 13, 2012
I am creating a program to simulate a tenpin bowling scoring system, and I'm using labels with the following name structure:
Player1Frame1Ball1, Player1Frame1Ball2, etc..
I have following variables also: CurrentPlayer, CurrentFrame, CurrentBall
I am hoping to use these variables to specify which label I would like to check the value of (the score achieved, placed in the label).
To test my experiments I have been trying to output the score of the first ball in the current frame in a msgbox, but to no success:
[Code].....
View 6 Replies
Jun 1, 2010
When I am concatenating object values together to form a string in VB.NET, is there a difference in performance or a recommended best practice between using the & concat or the + concat with calls to .ToString() on each object?
Example (which is faster or best practice):
Dim result1 As String = 10 & "em"
Dim result2 As String = 10.ToString() + "em"
View 4 Replies
Jan 25, 2012
I have combobox for year and combobox for month concatenated to make the date format "2012-01" My db field is RecordDate and is smallDateTime In my select statement im trying to use the left function to find match my concatenated string to the RecordDate field.Here is my code, hopefully someone can help me. Currently im getting the error "Conversion failed when converting date and/or time from character string."
Dim newRecordDate As String = (CStr(ComboBox2.SelectedValue)) & "-" & val1
Dim val10 As String = CStr(Convert.ToDateTime(newRecordDate))
Dim val21 As String = Microsoft.VisualBasic.Right(val10, 7)
MsgBox(val10)
[code]....
View 5 Replies
Apr 30, 2009
I'm under the impression that these two commands result in the same end, namely incrementing X by 1 but that the latter is probably more efficient.If it is correct, why should the latter be more efficient? Shouldn't they both compile to the same IL?
View 17 Replies
Oct 5, 2009
I've developed a .NET application that, among other things, does the following:Uses WebClient to retrieve data from a remote server.
Serves as a socket server to 2 'satellite' applications run on the same machine or on a LAN.When I run the app in the VS IDE, it works great. It quickly gets the data from the remote server and communicates perfectly with the 2 satellites.However, when I build it and run it as an EXE, the response from the remote server is very slow and its communication with the 2 satellite applications become very poor.Is there some important difference between running an app in the IDE and running it as an EXE that could effect it like this?
View 1 Replies
Apr 9, 2011
For every member object I have to declare the variable 3 times.One in the declaration. One for property declaration. One to tell the compiler to synthesize all the function. Another one to release all those members from memory.Then I learn about Core Data. I generate diagram, poof the classes are made from me and a lot of things are done behind the screen of that visible classes.
Basically Core Data in Objective C represents some form of relational databases. Of course those databases can have relationship, including many to many relationship. The additional detail of having a third table for many to many relationship is already done.Then, there is indexed property so we can search faster. That's also done.
View 1 Replies
Jan 12, 2009
I have thought of a new project to keep me busy for a while, and it involves a more advanced GUI, specifically I want to display a map and put objects on it or highlight certain areas for example. I've been searching the forum for a little while and ran into two options for more advanced GUI building: WPF and GDI.
View 2 Replies
Sep 11, 2011
The following code shoudl put 2 commas after each entry in the x array. It concatenates commas just file using an index. It does not concateante when you use "for each".
Sub SummaryHeadings()
Dim x() As String = {"Found No Help",
"One",
[code]....
View 4 Replies
Jun 21, 2010
i am not able to use connection string?
View 1 Replies
Dec 8, 2010
Can anyone tell me what the technical difference is between Application.Exit() and End?Why would you choose to use one over the other, for example?
View 5 Replies
Nov 19, 2010
I wanted to know what (if any) differences there are to using the SQL Transaction within the application versus written into the stored procedure using TSQL statement. We would need to restructure the stored procs and vb code to get this to work and I'm not sure it would be worth the effort at this time.
Public Sub RetrieveTData(ByVal cID As String, ByVal cnn As SqlConnection) As Boolean
Dim sqlTran As SqlTransaction
cnn.Open()
sqlTran = cnn.BeginTransaction
[code].....
We aren't certain whether the timeout is occurring in DataAlreadyTransferred() or usp_BigNasty_CopyDataFromDB1toDB2 due to how the try/catch is written. We can restructure this code, but will take a week or so to get it to production (no errors occur on test/dev today)
DB1 - permanent storage, used by other applications as well
DB2 - working set, used only by Web App
DataAlreadyTransferred(cID) first checks to see if DB2 has any copies of the records, if DB2 does and those records are clean it deletes them (data could have changed in DB1 and we want the most up-to-date version). If DB2's data is dirty it is left alone and no data is deleted.
usp_BigNasty_CopyDataFromDB1toDB2 copies rows from approximately 20-30 different tables and copies over the perm copies from DB1 into DB2, essentially creating a working set from which the Web App can access
We are aware this is inefficient and are examining ways to improve it, just haven't had time yet... I believe by having the transactions in the app code it's locking many more tables than is really needed. If we move them to the stored procs, less tables will be locked at one time thus improving our chances of removing deadlock conditions/timeout issues we're seeing today. Just not sure on this..
View 2 Replies
Apr 28, 2009
What are the situations and their associated benefits of using Generics over Inheritance and vice-versa, and how should they be best combined?I'm going to try to state the motivation for this question as best I can:I have a class as shown below:
[Code]...
Now suppose I have a repository that takes an InformationReturn argument, that has to strore different fields in a DB depending on the type of Info object T is. Is it better to create different repositories each for the type T is; one repository that uses reflection to determine the type; or is there a better way using inheritance capabilities over/with generics?
View 6 Replies
Dec 18, 2010
Deviding an int by zero, will throw an exception, but a float won't - at least in Java. Why a float have an additional NaN info, while int haven't?
View 6 Replies