Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how to assign variable

how to assign variable

Scheduled Pinned Locked Moved Visual Basic
helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nashes
    wrote on last edited by
    #1

    hi, i have a problem. I am using Visual Basic and is using File System Object. Now after i create a text file, i want to assign variables.. Dim fso As New FileSystemObject Dim fsoStream As TextStream ' Create a text file, and return a reference to a TextStream Set fsoStream = fso.CreateTextFile("c:\junk\junk.txt", True) ' Write to the file fsoStream.WriteLine "First line in the text file." fsoStream.WriteBlankLines 2 fsoStream.WriteLine "Line after two blank lines." fsoStream.Close Set fsoStream = Nothing Set fso = Nothing The letters in bold is the probleam i am having.. i want to assign a variable instead of String text.. Aslo wats the meaning of reading file..i wrote the code but it does nothing Nash Hon

    N 1 Reply Last reply
    0
    • N Nashes

      hi, i have a problem. I am using Visual Basic and is using File System Object. Now after i create a text file, i want to assign variables.. Dim fso As New FileSystemObject Dim fsoStream As TextStream ' Create a text file, and return a reference to a TextStream Set fsoStream = fso.CreateTextFile("c:\junk\junk.txt", True) ' Write to the file fsoStream.WriteLine "First line in the text file." fsoStream.WriteBlankLines 2 fsoStream.WriteLine "Line after two blank lines." fsoStream.Close Set fsoStream = Nothing Set fso = Nothing The letters in bold is the probleam i am having.. i want to assign a variable instead of String text.. Aslo wats the meaning of reading file..i wrote the code but it does nothing Nash Hon

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      it depends on what type of variable is. If it is a string then it is pretty straightforward:

      Dim abc as String
      ...
      fsoStream.WriteLine abc

      However, if it's some other type, you would have to do some type casting:

      Dim abc as Integer
      ...
      fsoStream.WriteLine CStr(abc)

      Keep in mind however that some variables cannot be type-casted. Hope that helps Notorious SMC


      The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
      Get your facts first, and then you can distort them as much as you please Mark Twain

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups