Solved

Problem to the item

Posted on 2015-01-27
2
94 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

776 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