Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Syntax problem with VB.....pls help

  • 06-07-2001 06:11PM
    #1
    Closed Accounts Posts: 2,313 ✭✭✭


    Its a very simple problem, I just dont have the solution smile.gif

    I want to write a string to a file. Generally the string is enclosed in invertad commas --> ""

    The problem is, the string itself contains inverted commas, so when VB sees this it ends the string prematurely. How do I put inverted commas into a string?

    EG.

    write #1, "string goes right "here" but fuks up cause of commas around here"

    Perhaps there is another way around it?

    Ta in advance from a noobie.


Comments

  • Registered Users, Registered Users 2 Posts: 380 ✭✭dogs


    <font face="Verdana, Arial" size="2">Originally posted by Paladin:

    write #1, "string goes right "here" but fuks up cause of commas around here"
    </font>

    write #1, "string goes right \"here\" but fuks up cause of commas around here"


  • Moderators, Social & Fun Moderators Posts: 10,501 Mod ✭✭✭✭ecksor


    Didn't know you could backslash quotes like that in VB. Usually you just doublequote, like "" instead of "


  • Closed Accounts Posts: 6,601 ✭✭✭Kali


    nope you can't backslash in VB, as said the doublequote does the job.


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    I never heard of that doublequoting thing before, I thought you had to use the ascii or something, hmmm...

    very interesting indeed, after a swift search me up, I must concur. I also must take my hat of to you sirs.


  • Closed Accounts Posts: 2,313 ✭✭✭Paladin


    Cheers lads. Turns out ascii values worked for me too.
    I had tried double quotes, but the string ran onto a few more lines and the syntax checker had problems with it :/ but now Ive it sorted.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 380 ✭✭dogs


    Erm, oops, sorry :) been a while since I had to touch VB *shudder*. "" is the best approach, or if you want to go all QBasic'y you can use the ASCII values.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    There is a Chr function in VB. Just us the Ascii value of the character you want to put in. e.g. Chr(13) will but in a carraige return.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    double quote "Hello ""world""." Of course it's a pain in the backside to read.

    Another option is...

    quote = """"
    print "hello " + quote + "world" + quote + "."

    messy too.


Advertisement