Arcade Prehacks

Results 1 to 5 of 5

Thread: VB 2010 help

  1. #1
    Senior Member
    Join Date
    Jul 2008
    Posts
    1,871

    VB 2010 help

    Okay, so i need some help with VB.

    How do I return strings from a file into a variable?
    I mean...is it possible with something like
    [color=#0000FF]
    Code:
    Dim variableOne as String = (code which reads information from file)
    [/color]

    AND how to check if a file exists)
    I remember that some language does it like this:[color=#0000FF]
    Code:
    if (fileexists) ("C:/path/to/file")
    [/color] and so on

  2. #2
    Administrator selectLOL's Avatar
    Join Date
    May 2010
    Posts
    3,290

    Re: VB 2010 help

    Try this:
    Code:
    IO.File.Exists(path)
    Returns true if the file exists.
    My website: http://selectlol.com/
    My second game: Play it now

    Its easier to find intelligent life in the universum than in the internet.

  3. #3
    Senior Member
    Join Date
    Jul 2008
    Posts
    1,871

    Re: VB 2010 help

    How could I use that witha if argument or whatever it's called?
    I need to check if a file exists, if it does, open file, else: return an error message (taken care of the msg part)

  4. #4
    Administrator selectLOL's Avatar
    Join Date
    May 2010
    Posts
    3,290

    Re: VB 2010 help

    Here for your file:
    Code:
    If IO.File.Exists("C:/path/to/file") Then
    ' File exists
    Else
    ' File doesnt exist
    End If
    Now you can open the file if it exists.
    Code:
    Dim load_file As System.IO.StreamReader
    If IO.File.Exists("C:/path/to/file/test.txt") Then
         load_file = IO.File.OpenText("C:/path/to/file/test.txt")
         ' Other code which you want to do
         load_file.Close() ' You need to close it at the end
    Else
         ' Maybe showing a message or something else
    End If
    My website: http://selectlol.com/
    My second game: Play it now

    Its easier to find intelligent life in the universum than in the internet.

  5. #5
    Senior Member
    Join Date
    Jul 2008
    Posts
    1,871

    Re: VB 2010 help

    Thanks, you're the man.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •