How to display a text file when a button is clicked

How to display a file (*. Txt) by pressing a command button

Using VB 6

Am New for VB 6

How to display the contents of a file when a button is clicked

The data is stored in a text file, ex 1.txt when you click on the buttion command, the 1.txt file will open and the 1.txt data should display

Need help with VB 6?

-1
source share
4 answers

To simply open the file using the current default file handler, try using the ShellExecute API function.

Here is an example .

+1
source

Add a text field to the form, make it multiline = true, add a button to the form. And in the button click handler add the following:

Private Sub Button1_Click()
  Dim iFile As Long
  Dim strFilename As String
  Dim strTheData as String

  strFilename = "C:\1.txt"

  iFile = FreeFile

  Open strFilename For Input As #iFile
   strTheData = StrConv(InputB(LOF(iFile), iFile), vbUnicode)
  Close #iFile
  text1.text=strThedata
End Sub

.

. , , MarkJ . MarkJ, .)

+5

Stefan : . - - VB6.

Open strFilename For Input As #iFile
strTheData = Input$(LOF(iFile), #iFile)
Close #iFile  

, 62 " ", ASCII . ( , ).

, : VB6 (), , .

Open strFilename For Input As #iFile
strTheData = StrConv(InputB(LOF(iFile), iFile), vbUnicode)
Close #iFile  

: , ANSI Unicode , . , .

+4

, , VB6. ( , , , , , , , , ).

Googling for VB6 Tutorial will provide many links, this one looks good

Hope this helps and apologizes if I am wrong :)

+3
source

Source: https://habr.com/ru/post/1720440/


All Articles