473,503 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i put some spaces in my string in VB.Net

121 New Member
hello, i know some of your may think that this question have been answered thousand time. I agree but none of the solutions given worked for me.

i have string like
Expand|Select|Wrap|Line Numbers
  1. Dim Test as String = "abc " & " def" 
what above code does is gives is "abc def" as output, what i want is "abc--------def" (where hash sign is spaces i need)

i have tried
Expand|Select|Wrap|Line Numbers
  1. Dim Test as String = "abc----" & "----def" 
for some reason (dot)net only takes it as one single space. check above(1) example ,i gave two spaces but it got converted to one space.

Expand|Select|Wrap|Line Numbers
  1. Dim Test as String = "abc" & Char(9) & "def" 
doesn't work (found char(9) solution on internet)

Expand|Select|Wrap|Line Numbers
  1. Dim Test as String = "abc" & space(8) & "def"
doesnot work

I have tried another 10 different option but none seems to be working for me.

Any help will be appreciated.

Regards
Sep 8 '10 #1
18 32213
Monomachus
127 Recognized Expert New Member
Have you tried classic .NET string.Concat()?
Sep 8 '10 #2
pod
298 Contributor
is this for VB or ASP?
Sep 8 '10 #3
jay123
121 New Member
Its VB.. (by the way whats minimum length of message that system allows here)
Sep 9 '10 #4
Monomachus
127 Recognized Expert New Member
if it's VB and not VB.NET than u're in the wrong forum.
Sep 9 '10 #5
pod
298 Contributor
I believe jay123 meant vb.net, my question should have been "is this for VB.NET or ASP.NET?"
Sep 9 '10 #6
pod
298 Contributor
jay123, I would like to reproduce your problem but I need to know , on what do you display your string? on a caption, in a text box, on a messagebox?
Sep 9 '10 #7
jay123
121 New Member
pod,

Its vb.net, I have a label which need to show some text. The problem i am facing is like. i need to display the string as a label text as

Expand|Select|Wrap|Line Numbers
  1. Label.Text = "abc" & "bcf" & "efg"
but their has to be tab(i am not sure if its tab difference but i need to give some space betwen them) difference between "abc" and "def". i have tried different ways but no gain.

Jay
Sep 10 '10 #8
pod
298 Contributor
Sorry, I am unable to reproduce your problem. If you could attach all of your function's code as a text file (just the one file where your code resides), maybe we could find the problem.

here are a few more troubleshooting methods to try:

try changing the font of your label to "Courrier"

..and also try this code (if you haven't already):
Expand|Select|Wrap|Line Numbers
  1. Label.Text = "abc" & "   " & "efg"
  2.  
  3.  
  4.  
Sep 10 '10 #9
jay123
121 New Member
Hi Pod,
I have tried the given solution but thats the problem, no matter how many spaces you give. it only takes one space
ex
Expand|Select|Wrap|Line Numbers
  1.  label1.text = "abc2 & "         " & "efg"
and
Expand|Select|Wrap|Line Numbers
  1. label1.Text = "abc" & " " & "efg"
gives same result.

my code is
Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ": " & "No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode
where Label1 and Postcode are string variables.
now i want above string to be displayed as
Expand|Select|Wrap|Line Numbers
  1. Label1Text:      No. 1 RG1 7UQ
, instead it comes out as
Expand|Select|Wrap|Line Numbers
  1. Label1Text: No. 1 RG1 7UQ
(check space between ':' and 'No.'
Sep 13 '10 #10
pod
298 Contributor
... looking at your code here
Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ": " & "No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode
the line above displays "Label1Text: No. 1 RG1 7UQ" ... as it should


now if you want more space between the ": " and the "No. " the line of code should be :
Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ":        " & "No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode

or let's even simplify it a little more

Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ":             No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode
let me know if I hit the nail on the head ...or on my finger :)
Sep 13 '10 #11
jay123
121 New Member
It doesnt work. We will assume that if we give space beteween two characters, it should take that space and display accordingly but strangely it only takes one space (no matter how many we give)
ex
Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ":             No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode
and
Expand|Select|Wrap|Line Numbers
  1. lblRiskSummaryConditions.Text = Label1 & ": No. " & CInt(ChildRisk - Me.RiskId) & " - " & Postcode
gives same result as
Labeltext: No 1 RG1 7UQ

its really a classic one now. i never knew this gonna be that complicated..(it just a space microsoft :) )
Sep 14 '10 #12
pod
298 Contributor
it's as if you had the function "Replace" running for everything, or some other function such as the TRIMALL macro http://www.mvps.org/dmcritchie/excel/join.htm#trimall.

If the problem is not in the portion of the script you displayed, one can only presume the problem resides in the remainder of your project.

Are you importing some DLLs, that might have text converting macros?

Can you post more code?
Sep 14 '10 #13
jay123
121 New Member
Its hard to figure out about DLL as its a big project and their are 100's of DLL floating around.

leave it mate, i'll post a solution if i manage to figure out what was causing the problem.

anyways thanks Pod for replying to this problem.
Sep 14 '10 #14
pod
298 Contributor
I wish you luck, and yes please do post the solution when you find it

merde!
(means best of luck)

P;oD
Sep 14 '10 #15
marcellus7
33 New Member
Try

Expand|Select|Wrap|Line Numbers
  1. Label.Text = "abc" & vbTab & "def"
Sep 14 '10 #16
jay123
121 New Member
vbTab doesn't work either..
Sep 15 '10 #17
arejandoro
1 New Member
This works.
+ " " + " " + " " +
Jun 26 '13 #18
Killer42
8,435 Recognized Expert Expert
...and you never did show us your final result, jay123. Ever get it to work?

If I'd been reading the thread back in 2010 I'd have asked you to pin down whether the odd behaviour was actually in what was stored, or just the display.
Jul 20 '13 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1607
by: MLH | last post by:
Suppose I have a sentence like "One Two Three Four" and I want it to say "One+Two+Three+Four". Taking into account that there might be more than a single space separating the words sometimes. ...
11
14976
by: gopal srinivasan | last post by:
Hi, I have a text like this - "This is a message containing tabs and white spaces" Now this text contains tabs and white spaces. I want remove the tabs and white...
3
2812
by: lino | last post by:
Hello, I have the following string: const char plaintext = "Fourscore and seven years ago our \ fathers brought forth upon this continent \ a new nation, conceived in liberty, and dedicated...
17
11777
by: tommy | last post by:
Hi all, I' m adding strings to some fields in my table via Access. The strings sometimes have trailing spaces and I really need to have it that way, but Access truncates trailing spaces. How can...
135
7342
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
3
12400
by: Luke - eat.lemons | last post by:
Hi, Could someone tell me the correct quotation to get around spaces in paths for: Server.MapPath("\\server\share\spaces in name.mdb") I know its bad practice to use spaces but...
8
17489
by: Joe Cool | last post by:
I need to map several columns of data from one database to another where the data contains multiple spaces (once occurance of a variable number or spaces) that I need to replace with a single...
3
4788
by: bstjean | last post by:
Hi everyone, I am trying to find an efficient way to perform a special query. Let me explain what I want. Let's say we are looking for all description that match "this is the target". In...
5
2937
by: brian.j.parker | last post by:
Hey all, I've noticed an obscure little quirk: it appears that if you use a login with trailing spaces on the name, SYSTEM_USER automatically trims those trailing spaces in SQL Server 2000, but not...
8
4723
by: drjay1627 | last post by:
hello, This is my 1st post here! *welcome drjay* Thanks! I look answering questions and getting answers to other! Now that we got that out of the way. I'm trying to read in a string and...
0
7093
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...
0
7287
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
7353
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...
0
7468
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
4689
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...
0
3180
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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 ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.