Results 1 to 6 of 6

Thread: My VBScript code not working properly

  1. #1
    Join Date
    Aug 2006
    Posts
    122

    My VBScript code not working properly

    I'm a complete newbie in VBScript, and there are lot of things that I am unaware of. I am developing an application that runs an HTML file offline. Now I want to transform each line of this text into a variable that Javascript can handle, also I need that HTML file to get the content of a txt file and send that value to a flash file loaded in the same HTML. I have successfully sent a Javascript variable to a flash file. To do the rest I'm trying to use a VBScript code that reads the content of an external text file and send to an HTML 'select' object. But due to some reason, it fails every time I run the HTML outside the desktop directory.
    As you simplify your life, the laws of the universe will be simpler; solitude will not be solitude, poverty will not be poverty, nor weakness.Henry David Thoreau

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: My VBScript code not working properly

    I am not able to get your question properly. How are you trying to run an HTML file offline.?? VBScript (VBS) is a Windows scripting language or also known as programming code that can be written as a text file and "executed" like an EXE file. A program such as Internet Explorer or the Windows Script Host carries out the instructions given in script code. Script is run by an interpreter. VBS can be used in several different ways. It originated as a webpage scripting language for Internet Explorer. It will be better if you provide your code.!

  3. #3
    Join Date
    Aug 2006
    Posts
    122

    Re: My VBScript code not working properly

    Thanks for sparing your precious time. I am written this code :
    Code:
    <html>
    
    <script Language="VBScript">
    
    sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
    
        Sub Window_OnLoad
            ForReading = 1
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objFile = objFSO.OpenTextFile _
                (sCurPath+"\lol.txt", ForReading)
            Do Until objFile.AtEndOfStream
                strLine = objFile.ReadLine
                Set objOption = Document.createElement("OPTION")
                objOption.Text = strLine
                objOption.Value = strLine
                FileContent.Add(objOption)
            Loop
            objFile.Close
        End Sub
    </SCRIPT>
    
    <body>
        <select size="5" name="FileContent" style="width:250"></select>
    </body>
    
    </html>
    I think that there should be something wrong in my code. Please let me know where I went wrong.!! Again Thanks..
    As you simplify your life, the laws of the universe will be simpler; solitude will not be solitude, poverty will not be poverty, nor weakness.Henry David Thoreau

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: My VBScript code not working properly

    You have written the code as
    Code:
    sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
    I would like to suggest you to make changes over here. In this line try to replace the period with your C drive, and see if it will run there. Your code should be like this
    Code:
    sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("C:\")
    Then don't put your file on the Desktop, put it in your C drive. Then you can modify your path accordingly.

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: My VBScript code not working properly

    Changing your path of your file that you are trying to Run should isolate the problem. You can try to use the code as suggested by the 'opaper'. Maybe changing the path can solve your problem. Since a path is complete and unambiguous if it provides a complete reference from the root of the specified drive. A complete path can only end with a path separator character (\) if it specifies the root folder of a mapped drive. You will also have to keep this in mind. If the problem persists, feel free to post again with proper and detailed information.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: My VBScript code not working properly

    I would like to tell you the common uses for VBScript, that include the following :
    • HTAs - create script-powered software that runs in an IE window using DHTML.
    • WMI - Windows Management Instrumentation. WMI functionality can be useful to non-admins. WMI is a script-accessible system used mainly by network administrators to manage multiple PCs on a network.
    • Windows scripting - handle Registry, files, settings, etc.
    • ASP - For webmasters using Windows servers, VBS can be used in ASP pages.

Similar Threads

  1. Replies: 4
    Last Post: 31-12-2011, 12:23 PM
  2. Tabpanel code not working properly in real software?
    By singham2011 in forum Software Development
    Replies: 5
    Last Post: 30-07-2011, 07:12 AM
  3. How to add VBScript code in a page
    By Aahlaadith in forum Software Development
    Replies: 6
    Last Post: 30-11-2010, 12:38 AM
  4. Replies: 3
    Last Post: 02-07-2009, 11:10 AM
  5. Error Code 31: DVD drive not working properly
    By Lord in forum Operating Systems
    Replies: 3
    Last Post: 03-03-2009, 06:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,516,853.07040 seconds with 16 queries