X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Message box with contents of a text file    
post Jul 15 2008, 09:05 AM

Posts: 691
Joined: 5-February 07
From: Northwest Ohio

Hello all. I have a comma delimited file named poskip.csv. I would like to read this file and put the contents into a message box, but am not sure of the best way to do this. My file would look like the following:
, 4, 7, 25
and I would like to create a message box that says "The following orders could not be processed at this time: PO 1, PO 4, PO 7, and PO 25." Do I import this file into a temporary table, and then loop through the records to come up with this, or is there an easy way to do this using only VBA?
Thanks for any help,
Go to the top of the page
Doug Steele
post Jul 15 2008, 09:28 AM

UtterAccess VIP
Posts: 21,962
Joined: 8-January 07
From: St. Catharines, ON (Canada)

Dim intFile As Integer
Dim strBuffer As String
Dim strFile As String
  strFile = "C:\Folder\poskip.csv"
  intFile = FreeFile
  strBuffer = Space(FileLen(strFile))
  Open strFile For Binary Access Read As intFile
  Get #intFile, , strBuffer
  Close #intFile
[color="green"]' At this point, strBuffer will contain the entire contents of the file.[/color]
Go to the top of the page
post Jul 15 2008, 09:47 AM

Posts: 18,324
Joined: 29-March 05
From: Wisconsin


I would read the Access help on the Split Function (to split the comma-delimited text into an array of values).

With this tool, you can split the comma-delimited data into an array of values. From there, you can assemble the string to be displayed in the textbox by looping through the array of values.

Hope this helps,

Go to the top of the page
post Jul 15 2008, 10:43 AM

Posts: 691
Joined: 5-February 07
From: Northwest Ohio

Thanks to both of you. I was able to get the contents of the file using Doug's suggestion, and then was able to split it into an array using the recommendation from Dennis so I could customize the message box a little bit more. When I was researching the Split function I came across a different way of getting the file contents into a string. Is there any benefit of using the following instead of the technique Doug gave?
It seems that it accomplishes the same thing. Is one better, or more reliable than the other?
Thanks for the help,
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    21st October 2018 - 09:30 PM