Search code examples
vbscript

saving input in a csv file VB script


Below script capture in a raw text file. But I want to save input in a csv file into cell. Kindly help

Dim employee_id, employee_name, system_running_status

employee_id = InputBox("Enter your Employee ID", "Employee ID")

employee_name = InputBox("Enter your Name", "Employee Name")

fission_running_status = InputBox("Did you Powered-On the system today (Yes/No) ?","Fission Server Status")

Set obj = CreateObject("Scripting.FileSystemObject")

Const ForWriting = 8

Set obj1 = obj.OpenTextFile("aap.txt", ForWriting)

obj1.WriteLine ("Employee: " & employee_name & "-" & employee_id & " turned on system on: ") & Now() & vbCr

obj1.Close                                            
Set obj=Nothing

Solution

  • You can simply reformat your output string:

    Set obj1 = obj.OpenTextFile("aap.csv", ForWriting)
    obj1.WriteLine employee_name & "," & employee_id & "," & Now() & vbCr