Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have made many user forms in the past. And I know you can have an
image show up in a user form. I am wondering if there is any way in which I can show to the user the contents of a text file (.txt) while they are making a choice in the user form (basically the text files could be one of two types and I want the user to be able to see it and then tell my macro which one it is). The text file will change each time, because in the previous dialog box I have them find the text file on their computer. Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could read in the text file and put the text in a textbox.
-- Regards, Tom Ogilvy "Chip" wrote in message ps.com... I have made many user forms in the past. And I know you can have an image show up in a user form. I am wondering if there is any way in which I can show to the user the contents of a text file (.txt) while they are making a choice in the user form (basically the text files could be one of two types and I want the user to be able to see it and then tell my macro which one it is). The text file will change each time, because in the previous dialog box I have them find the text file on their computer. Thanks in advance. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm not sure what you mean? How would I go about doing that? Any code
to get me started would be great. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use Low Level fileio
Private Sub CommandButton1_Click() strFile = "C:\xltext\myfile.txt" hFile = FreeFile Open strFile For Input As hFile Do While Not EOF(hFile) Line Input #hFile, strLine sStr = sStr & strLine & Chr(10) Loop Close #hFile UserForm1.TextBox1.Text = sStr End Sub RBSmissert posted this like which has some added information on low level file io http://www.applecore99.com/gen/gen029.asp Of course, if your text file is large, you may only want to read in a couple of lines Private Sub CommandButton1_Click() Dim strFile as String, hFile as long Dim strLine as String, icnt as long strFile = "C:\xltext\myfile.txt" hFile = FreeFile Open strFile For Input As hFile icnt = 0 Do While icnt < 5 Line Input #hFile, strLine sStr = sStr & strLine & Chr(10) icnt = icnt + 1 Loop Close #hFile UserForm1.TextBox1.Text = sStr End Sub -- Regards, Tom Ogilvy "Chip" wrote in message oups.com... I'm not sure what you mean? How would I go about doing that? Any code to get me started would be great. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Make sure the textbox property for multiline is set to true.
-- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Use Low Level fileio Private Sub CommandButton1_Click() strFile = "C:\xltext\myfile.txt" hFile = FreeFile Open strFile For Input As hFile Do While Not EOF(hFile) Line Input #hFile, strLine sStr = sStr & strLine & Chr(10) Loop Close #hFile UserForm1.TextBox1.Text = sStr End Sub RBSmissert posted this like which has some added information on low level file io http://www.applecore99.com/gen/gen029.asp Of course, if your text file is large, you may only want to read in a couple of lines Private Sub CommandButton1_Click() Dim strFile as String, hFile as long Dim strLine as String, icnt as long strFile = "C:\xltext\myfile.txt" hFile = FreeFile Open strFile For Input As hFile icnt = 0 Do While icnt < 5 Line Input #hFile, strLine sStr = sStr & strLine & Chr(10) icnt = icnt + 1 Loop Close #hFile UserForm1.TextBox1.Text = sStr End Sub -- Regards, Tom Ogilvy "Chip" wrote in message oups.com... I'm not sure what you mean? How would I go about doing that? Any code to get me started would be great. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Got it. Thanks...That's pretty cool.
|
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
By the way, Tom you are the man
|
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() All these 2 methods are reading the text file line by line. But I have very large text file (over 1000KB) needed to be put on the text box. I a bit waste time and maybe error . Is there any methods that I can put this large text file on the tex box, other than the reading text method? -- JaiJa ----------------------------------------------------------------------- JaiJai's Profile: http://www.excelforum.com/member.php...fo&userid=1948 View this thread: http://www.excelforum.com/showthread.php?threadid=34071 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried them?
That type of code reads in a file pretty fast. there are ways to modify that to read in a file to a variable in one go. -- Regards, Tom Ogilvy "JaiJai" wrote in message ... All these 2 methods are reading the text file line by line. But I have a very large text file (over 1000KB) needed to be put on the text box. It a bit waste time and maybe error . Is there any methods that I can put this large text file on the text box, other than the reading text method?? -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=340711 |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JaiJai,
Just put the whole file into a RichTextBox ? NickHK "JaiJai" wrote in message ... All these 2 methods are reading the text file line by line. But I have a very large text file (over 1000KB) needed to be put on the text box. It a bit waste time and maybe error . Is there any methods that I can put this large text file on the text box, other than the reading text method?? -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=340711 |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Yes, I have tried the all and it really time consuming to read and write line by line. The attached file is the text file (large file size) that I want to put on the textbox. Are there any other good methods ? +-------------------------------------------------------------------+ |Filename: CSV-htaa.zip | |Download: http://www.excelforum.com/attachment.php?postid=3653 | +-------------------------------------------------------------------+ -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=340711 |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub CommandButton1_Click()
Dim sStr As String strFile = "C:\Data6\CSV-htaa.txt" Hfile = FreeFile Open strFile For Input As Hfile i = LOF(Hfile) sStr = Input(i, #Hfile) Close #Hfile UserForm1.TextBox1.Text = sStr UserForm1.Show End Sub give it a try. -- Regards, Tom Ogilvy "JaiJai" wrote in message ... Yes, I have tried the all and it really time consuming to read and write line by line. The attached file is the text file (large file size) that I want to put on the textbox. Are there any other good methods ? +-------------------------------------------------------------------+ |Filename: CSV-htaa.zip | |Download: http://www.excelforum.com/attachment.php?postid=3653 | +-------------------------------------------------------------------+ -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=340711 |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Make sure Multiline is set to true for the textbox. Also, probably want to
display the vertical scrollbar. Private Sub CommandButton1_Click() Dim sStr As String strFile = "C:\Data6\CSV-htaa.txt" Hfile = FreeFile Open strFile For Input As Hfile i = LOF(Hfile) sStr = Input(i, #Hfile) 'Debug.Print Len(sStr) Close #Hfile With UserForm1.TextBox1 .MultiLine = True .ScrollBars = fmScrollBarsVertical .Text = sStr End With UserForm1.Show End Sub -- Regards, Tom Ogilvy "JaiJai" wrote in message ... Yes, I have tried the all and it really time consuming to read and write line by line. The attached file is the text file (large file size) that I want to put on the textbox. Are there any other good methods ? +-------------------------------------------------------------------+ |Filename: CSV-htaa.zip | |Download: http://www.excelforum.com/attachment.php?postid=3653 | +-------------------------------------------------------------------+ -- JaiJai ------------------------------------------------------------------------ JaiJai's Profile: http://www.excelforum.com/member.php...o&userid=19484 View this thread: http://www.excelforum.com/showthread...hreadid=340711 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding items to a combo box on a user form | Excel Discussion (Misc queries) | |||
Adding a new text box to user form | Excel Discussion (Misc queries) | |||
How to input file name in user form | Excel Programming | |||
Adding a counter to a User Form in Excel | Excel Programming | |||
Adding items to a spreadsheet from a user form listbox | Excel Programming |