Read and write into a file using VBScript

前端 未结 9 1453
轮回少年
轮回少年 2020-11-27 06:34

How can we read and write some string into a text file using VBScript? I mean I have a text file which is already present so when I use this code below:-

Set         


        
9条回答
  •  北海茫月
    2020-11-27 07:11

    You could put it in an Excel sheet, idk if it'll be worth it for you if its needed for other things but storing info in excel sheets is a lot nicer because you can easily read and write at the same time with the

     'this gives you an excel app
     oExcel = CreateObject("Excel.Application")
    
     'this opens a work book of your choice, just set "Target" to a filepath
     oBook = oExcel.Workbooks.Open(Target)
    
     'how to read
     set readVar = oExcel.Cell(1,1).value
     'how to write
     oExcel.Cell(1,2).value = writeVar
    
     'Saves & Closes Book then ends excel
     oBook.Save
     oBook.Close
     oExcel.Quit
    

    sorry if this answer isnt helpful, first time writing an answer and just thought this might be a nicer way for you

提交回复
热议问题