Advertisement
joris

Statistik

Dec 11th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub cmdOK_Click()
  2. Dim val As String, val2 As String, val3 As String
  3.  
  4. 'Creating text file==============================
  5.    If Depthvar = 1 Then
  6.         Open App.Path & "\score.txt" For Output As #1
  7.         Close #1
  8.     End If
  9.     If Depthvar = 4 Then
  10.         Open App.Path & "\score2.txt" For Output As #1
  11.         Close #1
  12.     End If
  13.     If Depthvar = 6 Then
  14.         Open App.Path & "\score3.txt" For Output As #1
  15.         Close #1
  16.     End If
  17.     '================================================
  18.    
  19.     'Writing text inside your text file============
  20.    If Depthvar = 1 Then
  21.         val = txtMudah.Text
  22.         Open App.Path & "\score.txt" For Output As #1
  23.     End If
  24.     If Depthvar = 4 Then
  25.         val2 = txtSedang.Text
  26.         Open App.Path & "\score2.txt" For Output As #1
  27.     End If
  28.     If Depthvar = 6 Then
  29.         val3 = txtSulit.Text
  30.         Open App.Path & "\score3.txt" For Output As #1
  31.     End If
  32.    
  33.     Print #1, val
  34.     Print #1, val2
  35.     Print #1, val3
  36.     '===============================================
  37.    Close #1
  38.     Unload Me
  39. End Sub
  40.  
  41. Private Sub Form_Load()
  42.     BacaData
  43. End Sub
  44.  
  45. Public Function BacaData()
  46.      Dim Proses1,Proses2 As String
  47.     ' Get a free file number
  48.    nFileNum = FreeFile
  49.     ' Open a text file for input. inputbox returns the path to read the file
  50.    Open App.Path & "\score.txt" For Input As nFileNum
  51.     lLineCount = 1
  52.     ' Read the contents of the file
  53.    Do While Not EOF(nFileNum)
  54.    Line Input #nFileNum, sNextLine
  55.    'do something with it
  56.   'add line numbers to it, in this case!
  57.   sNextLine = sNextLine & vbCrLf
  58.    sText = sText & sNextLine
  59.     Loop
  60.         txtMudah.Text = sText
  61.     ' Close the file
  62. Close nFileNum
  63.  
  64.     'Pada saat proses baca kemudian ambil data dan diproses kemudian munculkan MsgBox
  65.        Proses1 = sText
  66.         Proses2 = Replace(Proses1, " sec", "")
  67.     MsgBox(Proses2)
  68. End Function
  69.  
  70. Public Function BacaData2()
  71.     ' Get a free file number
  72.    nFileNum = FreeFile
  73.     ' Open a text file for input. inputbox returns the path to read the file
  74.    Open App.Path & "\score2.txt" For Input As nFileNum
  75.     lLineCount = 1
  76.     ' Read the contents of the file
  77.    Do While Not EOF(nFileNum)
  78.    Line Input #nFileNum, sNextLine
  79.    'do something with it
  80.   'add line numbers to it, in this case!
  81.   sNextLine = sNextLine & vbCrLf
  82.    sText = sText & sNextLine
  83.     Loop
  84.         txtSedang.Text = sText
  85.     ' Close the file
  86. Close nFileNum
  87. End Function
  88.  
  89. Public Function BacaData3()
  90.     ' Get a free file number
  91.    nFileNum = FreeFile
  92.     ' Open a text file for input. inputbox returns the path to read the file
  93.    Open App.Path & "\score3.txt" For Input As nFileNum
  94.     lLineCount = 1
  95.     ' Read the contents of the file
  96.    Do While Not EOF(nFileNum)
  97.    Line Input #nFileNum, sNextLine
  98.    'do something with it
  99.   'add line numbers to it, in this case!
  100.   sNextLine = sNextLine & vbCrLf
  101.    sText = sText & sNextLine
  102.     Loop
  103.         txtSulit.Text = sText
  104.     ' Close the file
  105. Close nFileNum
  106. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement