I have a Userform in my VBA app. I need the User to input a section,date,time,period, and interval(mins).these are from textboxes. How to get these input to be printed to a text file?The format is attached.pLs help.thanks.
Printable View
I have a Userform in my VBA app. I need the User to input a section,date,time,period, and interval(mins).these are from textboxes. How to get these input to be printed to a text file?The format is attached.pLs help.thanks.
VB Code:
[color="#0000A0"]Dim[/color] strSavedText [color="#0000A0"]As[/color] [color="#0000A0"]String[/color] strSavedText = txtSection.text & vbcrlf & txtDate.text [color="#00A000"]'etc[/color] [color="#0000A0"]Open[/color] "C:\Path\File.txt" [color="#0000A0"]For[/color] [color="#0000A0"]Output[/color] [color="#0000A0"]As[/color] #1 Print #1, strSavedText [color="#0000A0"]Close[/color] #1 Msgbox "Done!"
Thanks Alex..but i need a small logic there...If the user did not enter the date and time, then it should take the current system date and time(also in separate lines).Thankx
You could so that using this:
VB Code:
[color="#0000A0"]If[/color] cstr(trim(txtdate.text)) = "" [color="#0000A0"]Then[/color] strSavedText = strSavedText & [color="#0000A0"]Date[/color] [color="#0000A0"]Else[/color] strSavedText = strSavedText & cstr(trim(txtdate.text)) [color="#0000A0"]End[/color] [color="#0000A0"]If[/color]
The keyword Date as above grabs the current date, whilst the keyword Time grabs the current system time.
You might also want to lookup the format() function in MSDN if you want to alter the format of the date & time values.
Alex..need ur help again..I 've got a Shell func which passes 5 arguments(these 5 arguments should actually come from the txt file created above but I 've hardcoded it) How to pass it to my shell func in the module.This is my code.
:-
The aruments are after the DocName param..Thanks again.:rolleyes:PHP Code:Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
Debug.Print "yoyo"
StartDoc = ShellExecute(Scr_hDC, "Open", DocName, "2 03/11/2002 08:15:00 7 30", "C:\windows\desktop\CreateAct\", SW_SHOWNORMAL)
Debug.Print "yaya"
End Function
err, would that be this thread http://www.vbforums.com/showthread.p...hreadid=239651 you'd be referring to there by any chance? ;)
Give me a min ....
I dunno where the text file idea fits into all of this, but here's a sample project for you, it'll show a form with your textboxes, then pass the values over to your perl program - I've just tested it & the parameters are passed okay here
Alex...I understand how u did it...But why i wanted to read in from the text file is bcoz, all my functions are not in the same Form module as u did.. The place where i click a button is in Form B(which activates a Shell function) but the fields which I'm getting the parameters from is Form A... Do u get it now..???
Like for this:
it is impossible to do so inmy case coz strParameters is defined in my Form B but the txtSection.Text..etc etc is in Form A.U got my problem now?I was so glad tat u really took the effort to try it out to help me. Thankx alot.PHP Code:strParameters = txtSection.Text & "," & txtDate.Text & "," & txtTime.Text & ","
strParameters = strParameters & txtPeriods.Text & "," & txtMins.Text
Try this one!
Thank you alex..Its kinda helped me.Thanks for ur time n effort..