?
Solved

very simple!!! VERY!

Posted on 2003-03-18
17
Medium Priority
?
174 Views
Last Modified: 2010-05-01
Hi,
easy points:
1. code for an application which on load reads from a text file in the same directory called "browser.txt".
it does this once every 20 seconds.
if the text "asdf" is retrieved from the first line, it opens default browser.
if not, it keeps on trying to read the file every 20 seconds.
no labels, no command buttons. nothing.

2. an application which on load writes to a text file called "browser.txt" the text "asdf".
again. no labels or command buttons.

asap.
thanks.
0
Comment
Question by:11ods
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +2
17 Comments
 
LVL 3

Expert Comment

by:QJohnson
ID: 8164014
Reading the file is simple:

==========================================
dim nHandle as integer
dim sBuffer as string

nHandle = FreeFile
Open app.path & "\browser.txt" for input as #nHandle
Input #nHandle, sBuffer
Close #nHandle
'    now the value of the first line of text is in sBuffer
'    so do your testing
==========================================

Writing the file is simple, too.

==========================================
dim nHandle as integer
dim sBuffer as string

nHandle = FreeFile
Open app.path & "\browser.txt" for output as #nHandle
Print #nHandle, "asdf" & vbcrlf
Close #nHandle
==========================================

Now you just need to put a timer control on your form, set the interval to the desired time and put the code in its event so that it gets fired every 20 seconds.
0
 

Author Comment

by:11ods
ID: 8164079
i'm getting end of file errors

and i'm looking for full code

including how to set the timer etc..
0
 

Author Comment

by:11ods
ID: 8164108
and your app doesnt follow directions. it needs to open the default web browser once it gets "asdf"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

Expert Comment

by:mlmcc
ID: 8164124
Is this homework?

mlmcc
0
 

Author Comment

by:11ods
ID: 8164139
no i'm past that stage.
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8164140
Option Explicit
Dim fn As String

Private Sub Form_Load()
    fn = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") & "Browser.txt"
    If (Dir(fn) = "") Then
        Open fn For Output As #1
            Print #1, "ASDF"
        Close #1
    End If
End Sub

Private Sub Timer1_Timer()
    Dim msg As String
    If (Dir(fn) = "") Then
        Open fn For Input As #1
            While Not EOF(1)
                Line Input #1, msg
                If (msg = "ASDF") Then
                    Shell "C:\program Files\Internet explorer\Iexplorer.exe", vbNormalFocus
                    Close #1
                    Exit Sub
                End If
            Wend
        Close #1
    End If
End Sub
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8164143
insert timer from ur toolbox and set its interval to 20000
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8164158
No one is writing an application for you here even for 1000 points.  If this isn't enough help, maybe some other gracious individual will grace you with more.

But they shouldn't in my opinion.  

This is a forum for professional developers solving real world problems with a minimum amount of self-sufficiency who come here for hints to get them pointed in the right direction for a solution.  And they are happy to run with the hint and get their work done.  They don't come here looking for someone to do their job for them.
0
 

Author Comment

by:11ods
ID: 8164204
QJohnson.

i am not some professional developer. all i wanted is a simple application. if i dont know how to check for end of file errors then sorry.
all i was looking for is for someone to make a simple application. surely enough, someone kindly did.
if you posted something very vague which didnt work its not my fault that i do not want to give you the points.

also i am not planning to learn the whole visual basic language if all i need is a very simple application. i have some points, and i needed an application.
points + someone willing to write an application = works.

its not as if i asked for you to code me a graphic design application.
"dont have a cow".

avya2k: checking the application now ...
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8164341
You are asking for 2 complete applications.  Yes they are relatively easy to write, but as professinals we try to make the code maintainable and useful.

There are numerous websites where for a price someone will write complete applications.  This one would probably cost between $25 and $100 dependinng on exactly what you required.

In that price range you would get an executable and no source code.

mlmcc
0
 

Accepted Solution

by:
noCigar earned 304 total points
ID: 8164358
11ods: i agree compleatly.
plus. you dont need to pay that bullshit.
here you go.

application #1: to read. all you will need to do is add a timer object.
_____________________________________________________
Option Explicit
Dim intFileNum As Integer
Dim strData As String
Dim counter As Integer
Dim R As Long

Private Sub Form_Load()
 Timer1.Interval = 1000
 Timer1.Enabled = True
 intFileNum = FreeFile
End Sub

Private Sub Timer1_Timer()
counter = counter + 1
If (counter > 1000) Then
 Timer1.Enabled = False
Else
  Open App.Path & "\browser.txt" For Input As #intFileNum
  Do While Not EOF(intFileNum)
   Line Input #intFileNum, strData
    If (strData = "asdf") Then
      R = ShellExecute(Me.hwnd, "Open", "http://www.QJohnson.com", _
      vbNullString, App.Path, vbNormalFocus)
      Close #intFileNum
      Exit Sub
    End If
  Close #intFileNum
 Loop
 Close #intFileNum
End If
End Sub
0
 

Expert Comment

by:noCigar
ID: 8164360
also, for application # 1 add a module
which has the following code:

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hwnd As Long, ByVal lpOperation As String, _
        ByVal lpFile As String, ByVal lpParameters As String, _
        ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

0
 

Expert Comment

by:noCigar
ID: 8164371
application #2: to read the file. again insert a timer.

______________________________________________________
Private Sub Form_Load()
Timer1.Interval = 60000 'About 1 minute
Timer1.Enabled = True

Dim nHandle As Integer
Dim sBuffer As String
nHandle = FreeFile
Open App.Path & "\browser.txt" For Output As #nHandle
Print #nHandle, "asdf" & vbCrLf
Close #nHandle
End Sub



enjoy the FREE sourcecode.
0
 

Author Comment

by:11ods
ID: 8164376
excellent.

just what i was looking for.
well done.
looks like there are some professionals that dont only think about the money.

thank you for helping me.
lol at the web address you make the browser jump to :)
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8164659
11ods
may i know what was wrong in my answer just to improve myself
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8164660
sorry make 'answer' as comment
0
 

Author Comment

by:11ods
ID: 8164667
i was asking for two seperate applications.

and it didnt open default web browser for some reason...

but thanks a lot anyway. i really appriciate it.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question