Solved

Problem to the item

Posted on 2015-01-27
2
97 Views
Last Modified: 2015-01-28
Hi,
I don't know why I get the error attached,

to these codes
Public Function vbascr2main() Set objFSO=CreateObject("Scripting.FileSystemObject") : out1="z:\cmp2\list1.txt" : Set objFile = objFSO.CreateTextFile(out1,True) : Dim x1 : For each x1 in AVX.Item : objFile.Write x1.Name & "<br />" : Next : objFile.Close : End Function

Open in new window

0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 40574464
Try this.
Public Function vbascr2main() 
  Set objFSO=CreateObject("Scripting.FileSystemObject")
  out1="z:\cmp2\list1.txt"
  Set objFile = objFSO.CreateTextFile(outFile,True)
  Dim x1
  For each x1 in AVX.Item
    objFile.WriteLine x1.Name
  Next
  objFile.Close
End Function

Open in new window

0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 40574469
At first glance I don't see AVX as defined in your code  Therefore it will error when you try and loop through it.  I also don't recommend putting all that in one line of code as it makes it for someone who follows you to to read it.  I recommend you break it down, something like this:

Public Function vbascr2main()
	Dim x1

	Set objFSO=CreateObject("Scripting.FileSystemObject")
	out1="z:\cmp2\list1.txt"
	Set objFile = objFSO.CreateTextFile(out1,True)

	For each x1 in AVX.Item
		objFile.Write x1.Name & "<br />"
	Next
	
	objFile.Close
End Function

Open in new window


What error do you receive?
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using a hta file with MSSQL agent to schedule a script job 4 51
Vbscript & Batch: restart servers with delay condition 2 40
size of file 1 24
Permission on folders 6 25
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question