473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

loading html or txt file to visual basic program

1
hello! i just wanna ask on how to load an html or txt file from a certain monitoring software(specifically commView for WiFi) to VB programming language?

TnX a lot:)
Jul 18 '12 #1
2 1421
Guido Geurs
767 Expert 512MB
these are some examples how you can load a file:
1) IF you want to select a file:

Expand|Select|Wrap|Line Numbers
  1. Private Function Open_File()
  2. Dim STRTEMP As String
  3.    TextBox.Text = ""
  4.    On Error GoTo Cancel_Function
  5.    With CommonDialog
  6.       .CancelError = True
  7.       .Filter = "Text (.txt)|*.txt"
  8.       .InitDir = Environ$("USERPROFILE") & "\My Documents"
  9.       .DialogTitle = "Open a file..."
  10.       .ShowOpen
  11.       On Error GoTo Error_Open_File
  12.       Open .FileName For Input As #1
  13.          Do Until EOF(1)
  14.             Input #1, STRTEMP
  15.             TextBox.Text = TextBox.Text & STRTEMP
  16.          Loop
  17.       Close #1
  18.       Caption = Left(Caption, 26) & ": " & .FileName
  19.    End With
  20.    CMDunix2dos.Enabled = True
  21.    TEXTCHANGED = False
  22.    CMDsave.Enabled = True
  23.    CMDsaveAs.Enabled = True
  24.    MnuFile(2).Enabled = True
  25.    MnuFile(3).Enabled = True
  26. Exit Function
  27. Error_Open_File:
  28.    Close #1
  29.    MsgBox "There is an error opening the file"
  30. Exit Function
  31. Cancel_Function:
  32. End Function
2) directly:

Expand|Select|Wrap|Line Numbers
  1. Dim FF As Long
  2. Dim TotalFile As String
  3.     CommonDialog1.ShowOpen
  4.      FF = FreeFile
  5.     Open CommonDialog1.FileName For Binary As #FF
  6.     '  Allocate a buffer equal in size to the file
  7.     '  (see LOF function) so that the Get statement
  8.     '  can stuff text from the file into it.
  9.     TotalFile = Space(LOF(FF))
  10.     Get #FF, , TotalFile
  11.     Close #FF
  12.     Text1.Text = TotalFile
3) If the file is always on the same place

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim FileIn As Integer
  3.    FileIn = FreeFile
  4.    On Error GoTo Error_Laden
  5.    Open App.Path & "\document.txt" For Input As #FileIn
  6.       Do While Not EOF(FileIn)
  7.          Input #FileIn, inputdata
  8.          TEXTBLOCK = TEXTBLOCK & inputdata & vbCrLf
  9.       Loop
  10.    Close #FileIn
  11.       Text2.Text = TEXTBLOCK
  12. Exit Sub
  13. Error_Laden:
  14.    Close #FileIn
  15.    MsgBox ("Error loading !")
  16. End Sub
Or binary

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.    Dim Fle$, L&, Channel%, S$
  3.  
  4.    Fle$ = "c:\t\test.txt"
  5.    L = FileLen(Fle$)
  6.  
  7.    S$ = Space$(L)
  8.  
  9.    Channel = FreeFile
  10.    Open Fle$ For Binary Access Read As #Channel
  11.    Get #Channel, 1, S$
  12.    Close #Channel
  13.  
  14. End Sub
Jul 20 '12 #2
Killer42
8,435 Expert 8TB
Can you be more specific about what you want to do with the file? For example, do you simply want to copy the contents of the file into a text box?
Jul 27 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
I know we can write ASP with VB Script. Some people told me the big ASP projects usually use Visual Basic for the business logic. Is that the case? What I mean is an ASP project is the combination...
3
by: jack-b | last post by:
Hi, I'm wanting to load a html file into a panel (?) control because I want to keep my page header on the aspx page. First, is this the right approach to take? Second, how do I accomplish...
1
by: Davy | last post by:
Hi Can somebody help me to print a specific worksheet of an Excel file thru Visual Basic Thank Davy
1
by: MRAMIREZ | last post by:
This may be a simpler question then it sounds. I am tring to write a visual basic program that uses a GBIP card. But how or what actual command lines do I use to access the card in my compuer to send...
1
by: czi02 | last post by:
I'm using visual basic 6.0 and don't know how to connect the program that I've been made in html. Would u help. Thanks. Hope you'll send me some codes on connecting html to visual basic. Well thanks...
1
by: bondfresher11 | last post by:
Can any one tell me a program simulating a traffic light in visual basic????????
5
by: maghi85 | last post by:
hi, i've made a login web page that checks the username and password and then i call a function that loads the user on to another page. the only problem is... how do i load another page? I'm using...
4
by: jmd | last post by:
I am password protecting an html file. I have the password form set up and the check on the Perl side working. I just cant figure out how to get the Perl code to call an existing html program. The...
5
by: omotoyosi | last post by:
I developed a visual studio program and after running it , i discovered that the application is not seeing any database. Please how can i carry the database along with my application so that it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.