Listbox
Forums
I know how to get fieldnames in a list, but is there a way to get the content of a field in a listbox? (Such as debtor names or general ledger ID's)
Update:
I got to the point to summarize the selected field (general ledger ID) and export only the content of that field to a txt file and then import it.
Open WorkingDirectory & "\Temp.DEL" For Input As File1
Line Input #File1, Contents
MsgBox "The file contains: " & Contents
With this code i got the first line in a string, i can't figure out to get the rest in a string at the moment.
Sure, instead of the Readall
Sure, instead of the Readall you could use the Readline and place each line in an array. Check out my Append File Report script (http://ideascripting.com/ideascript/append-file-report) as it uses an array to store each line of the report and then I transfer the array to a text file.
I think i got it to convert
I think i got it to convert the text file to an array (line 150 to 152). But when i use the for each function to display the array content in a message every time i run it, i get subscript out of range on line 161. So i'am doining something wrong. I have looked at the Append File Report script, but I can not really isolate where what happens in the script.
You can't use the ReadAll
You can't use the ReadAll function in this case as you want to read it in line by line, that is why you are putting it in an array. If you want to use the readall then you create a string variable to hold the entire text (so long as it is less than 64,000 characters, that is around the limit of a string variable).
Also you have defined your array but you haven't actually initialized it, so far you have an array of nothing and you haven't said it should hold anything that is why you are getting the error.
So you need to create a new boolean variable called bFirstTime and set it as true:
Dim bFirstTime as Boolean
bFirstTime = True
Replace your for next loop with a Do Until loop as you don't know how many items will be in the file. The For Next loop is usually used when you know how many items to start off with.
Do Until objTextStream.AtEndOfStream 'must use a loop as there is no way to know how many items in the text file
If bFirstTime Then 'if this is the first item then redefine the array for 1 item
bFirstTime = False 'change this so this is only run once
ReDim text(0) 'initialize the array to 1 item
text(0) = objTextStream.ReadLine 'place the first item into the array
Else
ReDim preserve text(UBound(text) + 1) 'increase the array by 1 element
text(UBound(text)) = objTextStream.ReadLine 'place the next line at the end of the array
End If
Loop
I got it working, the one
I got it working, the one thing i changed to show the selected value in a messagebox is that when the script place the item in an array it is not in text() but in list3$() array. Because for some reason i didn't understand when i connected a string variable to the dialog droplistbox it would show the array number but not the content/text. How is the indentation style in my script?
Hi Robert,
Hi Robert,
It is much easier to read with the indentation. You still need some additional indentation, such as the Select Case ControlID$ should be indented twice more and everything that goes along with it as this is part of Case 2 so it should be indented accordingly.
The listbox returns the number of the item selected with the first item being 0 and so on. You have to match this up with the original array to obtain the string value of what you are looking for in the listbox.
Brian
Hi Robert,
Hi Robert,
I don't use the IDEAScript file functions anymore, there is an object available within windows that is really robust and does a lot more than the function in IDEA. It is called Scripting.FileSystemObject, if you do a google search on it you will find lots of info.
Here is your script using this object, the script first checks to make sure that the file exits and if it does then it reads all of it and puts the text in a string variable. There is also a function to read the text line by line.