473,396 Members | 1,996 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,396 software developers and data experts.

How Do I Wrap a Variable in Quotes

I'm working with a program to get directories and file types. If I could just get around this problem I'd be done. What I need to do is wrap a [variable] string in quotes before writing it to a text file. I am still pretty new to programming and I've been googling for about the past fourty-five minutes.

Here is the section of code that is giving me trouble.
Expand|Select|Wrap|Line Numbers
  1. Do While Not SR3.Peek = -1
  2.      SW3.WriteLine("compact /c /i " & SR3.ReadLine.Trim)
  3. Loop
What it's doing here is reading a file name from a separate text file and writing it to another text file so it can start compact.exe to compress the certain file. The reason I need to figure out how to wrap what's being written in quotes is because spaces in the file path mess things up.

To aid myself in making sense, here is an example of what is currently being written to the text file:
Expand|Select|Wrap|Line Numbers
  1. compact /c /i C:\ATI\Desktop.ini
Here is what I want:
Expand|Select|Wrap|Line Numbers
  1. compact /c /i "C:\ATI\Desktop.ini"
I've learned some good tricks by reading these forums, but this is my first time posting. I appreciate any help yo uguys could give!
Jun 9 '07 #1
5 1935
Killer42
8,435 Expert 8TB
Just concatenate Chr(34) in there - that's the double-quote character.

I think there's also a built-in constant named something like vbQuote or vbQuotes which contains the quote character, but don't remember for sure.
Jun 11 '07 #2
LacrosseB0ss
113 100+
Just throwing this out there, I don't know for sure, but if spaces are causing a problem, can you not replace those in the path? Use Replace(" ", "%20") is how I would go about it.

But, as previously mentioned, I haven't tried this. I'm going based on previous knowledge.

EDIT:
If Killer gives you a respose though, it's probably better than mine. I trust Killer's judgement. Try that first! ;)
Jun 11 '07 #3
DJWim
8
The first reply, incorporated in your code would look like

Expand|Select|Wrap|Line Numbers
  1. Do While Not SR3.Peek = -1
  2.      SW3.WriteLine("compact /c /i " & chr$(34) & SR3.ReadLine.Trim & chr$(34))
  3. Loop
Jun 11 '07 #4
It works flawlessly now!

Expand|Select|Wrap|Line Numbers
  1. Do While Not SR3.Peek = -1
  2.      SW3.WriteLine("compact /c /i " & Chr(34) & SR3.ReadLine.Trim & Chr(34))
  3. Loop
Many thanks to you Killer42!
Jun 12 '07 #5
Killer42
8,435 Expert 8TB
It works flawlessly now!
...
Many thanks to you Killer42!
Glad we could help! :)

But it was a team effort, not just me.
Jun 12 '07 #6

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

Similar topics

1
by: Simon Wigzell | last post by:
I send HTML formatted emails with links and images in them generated by my asp driven website. Occasionally the image will not appear and the link will not work. By looking at the email at the...
7
by: Richard Hollenbeck | last post by:
Help! I don't know why this isn't working: Private Sub Combo9_Change() Dim UsersCourseSelection As String UsersCourseSelection = Me("Combo9").Value Combo13.Visible = True 'the following...
8
by: name | last post by:
Back again for more critique... <grin> ------------------------------------------------ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #define MAX 10000
27
by: user | last post by:
Have require file with several query stings in it. Depending on user input one of strings is selected. Everything going along smoothly until I wanted to also input a variable in string. If I put...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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,...

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.