TPE
Tavvafi@gmail.com |
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
چند روال که اطلاعات را از یک متغیر رشته ای گرفته و سپس به عنوان یک messageBox نمایش می دهد. به این ترتیب اطلاعات جمع آوری شده در یک فایل متنی نوشته می شود.
در دو زیرروال زیر، یک رشته متنی را دریافت می شود، سپس در فایلی نوشته می شود، و سپس فایل برای ویرایش ، مشاهده و یا چاپ چاپ در برنامه Notepad باز می شود.
Sub WriteStringToFile(pFileName as String, pString as String) Dim intFileNum as Integer intFileNum = FreeFile ' change Output to Append if you want to add to an existing file ' rather than creating a new file each time Open pFilename For Output As intFileNum Print #intFileNum, pString Close intFileNum End Sub Sub SendFileToNotePad(pFileName as String) Dim lngReturn as Long lngReturn = Shell("NOTEPAD.EXE " & pFileName, vbNormalFocus) End Sub
مثالی دیگر:
Sub Test() ' Create a test string Dim strTestString as String strTestString = "Now is the time for, alas, poor Yorick, to Dunsinane woods to come. With gibberish like this." ' And a name for the file we're going to write Dim strTestFile as String strTestFile = "C:\TEMP\TESTFILE.TXT" ' be sure you have a C:\TEMP folder or it won't work ' Write it to a file Call WriteStringToFile(strTestFile, strTestString) ' and now let's see the file Call SendFileToNotePad(strTestFile) End Sub