mookie Posted February 25, 2005 Posted February 25, 2005 im trying to save the text from a string as "c:\program files" but when i do this chr(windows.systems.forms.keys.oemquote) & "c:\program files" & chr(windows.systems.forms.keys.oemquote) i end up with a funky result Quote
Administrators PlausiblyDamp Posted February 25, 2005 Administrators Posted February 25, 2005 Dim s As String = Convert.ToChar(34) & "c:\program files" & Convert.ToChar(34) would work, although this does rely on you guessing the correct location for the program files folder... A better soulution would be to use Dim s As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders snarfblam Posted February 25, 2005 Leaders Posted February 25, 2005 Why are either of you using a function to place quotes in strings? Plausibly Damp is right about the Environment.GetFolderPath function. If you must include quotes in your string, however, do it like this: Dim s As String = """C:\Program Files""" The double double quotes inside the outmost quotes will be parsed by the compiler as single double quotes... almost like an escape sequence. It looks confusing, but try it. Quote [sIGPIC]e[/sIGPIC]
mookie Posted February 25, 2005 Author Posted February 25, 2005 close but that gives me double quotes. Im looking it up for the single but its obviously not 22 either Quote
mookie Posted February 25, 2005 Author Posted February 25, 2005 Im not just doing the program files folder. Im creating aliases for a program Quote
Leaders snarfblam Posted February 26, 2005 Leaders Posted February 26, 2005 In your origional message: im trying to save the text from a string as "c:\program files" you used "double quotes". If you want "double quotes" then enter the string like Dim s As String = """this""" '= "This" If you want 'single quotes' (which i don't think you do) then enter the string like Dim s As String = "'this'" '= 'This' If you mean something else then I don't follow. Quote [sIGPIC]e[/sIGPIC]
mookie Posted February 27, 2005 Author Posted February 27, 2005 ok, im still not getting this right. what im trying to do, is list a number of aliases into a list box. this gets done by loading a text file, and looking at each line for the word "*commandalias". I then split the alias into a list array by the following dim list() as string list = split(newline, " " ) what i need to do then is remove the quotes from the string in the text file. im currently doing the following Dim str As String Dim newstr As String Dim id As Integer Do While InStr(list(1), Windows.Forms.Keys.OemQuotes) <> -1 id = InStr(list(1), Windows.Forms.Keys.OemQuotes) str = Mid(list(1), id + 1, Len(list(1))) list(1) = str Loop the problem im having is that it doesnt remove anything. If i replace the str = Mid(list(1), id + 1, Len(list(1))) with str = Mid(list(1), id + 2, Len(list(1))) I remove quotes from most strings but then i start removing the actual word. such as """""word""" ends up "ord" Quote
Administrators PlausiblyDamp Posted February 27, 2005 Administrators Posted February 27, 2005 Don't use the Windows.forms.Keys enumeration in place of ascii characters, it reports the keyboard scan code not the ASCII character. Use either the syntax I posted above or the solution offered by marble eater - they will work with embedded quotes correctly. Rather than using mid you may want to look at the .SubString method of your string variable, also remember the indexes into the string are 0 based, if you want to start at the 4th letter for example you need to specify a start index of 3. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.