Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub cmdOK_Click()
- Dim val As String, val2 As String, val3 As String
- 'Creating text file==============================
- If Depthvar = 1 Then
- Open App.Path & "\score.txt" For Output As #1
- Close #1
- End If
- If Depthvar = 4 Then
- Open App.Path & "\score2.txt" For Output As #1
- Close #1
- End If
- If Depthvar = 6 Then
- Open App.Path & "\score3.txt" For Output As #1
- Close #1
- End If
- '================================================
- 'Writing text inside your text file============
- If Depthvar = 1 Then
- val = txtMudah.Text
- Open App.Path & "\score.txt" For Output As #1
- End If
- If Depthvar = 4 Then
- val2 = txtSedang.Text
- Open App.Path & "\score2.txt" For Output As #1
- End If
- If Depthvar = 6 Then
- val3 = txtSulit.Text
- Open App.Path & "\score3.txt" For Output As #1
- End If
- Print #1, val
- Print #1, val2
- Print #1, val3
- '===============================================
- Close #1
- Unload Me
- End Sub
- Private Sub Form_Load()
- BacaData
- End Sub
- Public Function BacaData()
- Dim Proses1,Proses2 As String
- ' Get a free file number
- nFileNum = FreeFile
- ' Open a text file for input. inputbox returns the path to read the file
- Open App.Path & "\score.txt" For Input As nFileNum
- lLineCount = 1
- ' Read the contents of the file
- Do While Not EOF(nFileNum)
- Line Input #nFileNum, sNextLine
- 'do something with it
- 'add line numbers to it, in this case!
- sNextLine = sNextLine & vbCrLf
- sText = sText & sNextLine
- Loop
- txtMudah.Text = sText
- ' Close the file
- Close nFileNum
- 'Pada saat proses baca kemudian ambil data dan diproses kemudian munculkan MsgBox
- Proses1 = sText
- Proses2 = Replace(Proses1, " sec", "")
- MsgBox(Proses2)
- End Function
- Public Function BacaData2()
- ' Get a free file number
- nFileNum = FreeFile
- ' Open a text file for input. inputbox returns the path to read the file
- Open App.Path & "\score2.txt" For Input As nFileNum
- lLineCount = 1
- ' Read the contents of the file
- Do While Not EOF(nFileNum)
- Line Input #nFileNum, sNextLine
- 'do something with it
- 'add line numbers to it, in this case!
- sNextLine = sNextLine & vbCrLf
- sText = sText & sNextLine
- Loop
- txtSedang.Text = sText
- ' Close the file
- Close nFileNum
- End Function
- Public Function BacaData3()
- ' Get a free file number
- nFileNum = FreeFile
- ' Open a text file for input. inputbox returns the path to read the file
- Open App.Path & "\score3.txt" For Input As nFileNum
- lLineCount = 1
- ' Read the contents of the file
- Do While Not EOF(nFileNum)
- Line Input #nFileNum, sNextLine
- 'do something with it
- 'add line numbers to it, in this case!
- sNextLine = sNextLine & vbCrLf
- sText = sText & sNextLine
- Loop
- txtSulit.Text = sText
- ' Close the file
- Close nFileNum
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement