Logging inputbox input

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Is there a way to log all input that is entered through a inputbox? I have a
inputbox in a macro that a user enter data into. What I would like to

through that inputbox.

Dennis
=========
 
Dennis,

You could take all input bad write it out to a text file. Lookup 'Writing
Data to Files' in VBA help.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
I'm lost at this point. Here's what I have so far, but don't even know if I'm
on the right track

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.WriteLine (x)
a.Close

x is a variable that the input box fills. I do get a log from this but
obviously it just x in the log and it doesn't append.

Dennis
==========
 
This WebAddress has a decent spiel on low level I/O.

Controlling File Access with Visual Basic for Applications
http://support.microsoft.com/support/excel/content/fileio/fileio.asp

----------------------------------------------------------------------------------------------

Sub LogFile(varV As Variant)
'' strX is the value from your InputBox.

Const strFile As String = "YourFile.txt"
Dim intFileNum As Long

intFileNum = FreeFile
Open strFile For Append As #intFileNum
Print #intFileNum, Now & " : " & varV
Close #intFileNum

End Sub

Sub Tester()
Dim varX As Variant

varX = InputBox(Prompt:="Enter your value.")
Call LogFile(varX)

End Sub

Tested using Excel SR2 on W98.

HTH
Paul
 
DEnnis,

I was thinkling of more basic than FSO. This is a sample of that

Dim myVar, FileNumber
FileNumber = FreeFile ' Get unused file number.
Open "InputLog.txt" For Output As #FileNumber ' Create file name.

myVar = GetAndLogInput("Supply a date", "Log input test", FileNumber)

myVar = GetAndLogInput("Supply a number", "Log input test", FileNumber)

Close #FileNumber ' Close file.

Function GetAndLogInput(prompt As String, title As String, FileNumber)
Dim ans
Dim inTime As String


ans = InputBox(prompt, title)
inTime = Format(Now, "dd mmm yyyy hh:mm:ss") & ": "

Write #FileNumber, inTime & prompt
Write #FileNumber, inTime & ans
Write #FileNumber, ""

GetAndLogInput = ans

End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top