Advertisement
Guest User

Oppgave8

a guest
Oct 31st, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2. Option Explicit
  3.  
  4.  
  5.  
  6. ' Tømmer skjema når det lastes
  7. Private Sub Form_Load()
  8.  
  9.     Me.txtDiagnose = ""
  10.     Me.txtJournal = ""
  11.     Me.txtResept = ""
  12.  
  13. End Sub
  14.  
  15.  
  16.  
  17.  
  18.  
  19. Private Sub txtJournal_AfterUpdate()
  20.  
  21.     Dim i As Integer
  22.     Dim j As Integer
  23.     Dim reseptDel As String
  24.     Dim diagnoseDel As String
  25.     Dim missing_rTag As Module
  26.  
  27.  
  28.    
  29.  
  30.  
  31. '   Lar programmet gå igjennom teksten tegn for tegn
  32.  
  33.  
  34.     For i = 1 To Len(Me.txtJournal)
  35.  
  36.  
  37.  
  38.  
  39. ' Lager en under Loop for <resept> start-tag, med feilsjekking
  40.  
  41.     If Mid(Me.txtJournal, i, 8) = "<resept>" Then
  42.  
  43.     For j = i To Len(Me.txtJournal)
  44.    
  45.         If Mid(Me.txtJournal, j, 9) = "</resept>" Then
  46.             reseptDel = Mid(Me.txtJournal, i + 8, j - (i + 8))
  47.             Me.txtResept = Me.txtResept & " " & reseptDel
  48.             i = j
  49.             Exit For
  50.            
  51.         ElseIf Mid(Me.txtJournal, j, 10) = "<diagnose>" Then
  52.             GoTo rTag
  53.         ElseIf Mid(Me.txtJournal, j, 11) = "</diagnose>" Then
  54.             GoTo rTag
  55.         ElseIf Mid(Me.txtJournal, j, 8) = "<resept>" And j > 8 Then
  56.             GoTo rTag
  57.         ElseIf (j + 8) = Len(Me.txtJournal) Then
  58.             GoTo rTag
  59.         End If
  60.        
  61.  
  62.        
  63.        
  64.  
  65.             Next j
  66.         End If
  67.  
  68.  
  69. ' Lager en under Loop for <diagnose> tagen med feilsjekking
  70.  
  71.     If Mid(Me.txtJournal, i, 10) = "<diagnose>" Then
  72.    
  73.         For j = i To Len(Me.txtJournal)
  74.             If Mid(Me.txtJournal, j, 11) = "</diagnose>" Then
  75.                 diagnoseDel = Mid(Me.txtJournal, i + 10, j - (i + 10))
  76.                 Me.txtDiagnose = Me.txtDiagnose & " " & diagnoseDel
  77.                 i = j
  78.                 Exit For
  79.             ElseIf Mid(Me.txtJournal, j, 8) = "<resept>" Then
  80.                 GoTo dTag
  81.             ElseIf Mid(Me.txtJournal, j, 9) = "</resept>" Then
  82.                 GoTo dTag
  83.             ElseIf Mid(Me.txtJournal, j, 10) = "<diagnose>" And j > 10 Then
  84.                 GoTo dTag
  85.             ElseIf (j + 11) = Len(Me.txtJournal) Then
  86.                GoTo dTag
  87.             End If
  88.        
  89.    
  90.        
  91.    
  92.    
  93.    
  94.    
  95.             Next j
  96.          End If
  97.                    
  98.     Next i
  99.  
  100.     Exit Sub
  101.  
  102.  
  103. ' For rydde litt i koden, har jeg satt feilmeldingene som en GoTo
  104.  
  105. rTag:
  106.     Call MsgBox("Sjekk at rett antall tags for resept er brukt")
  107.     Exit Sub
  108.  
  109. dTag:
  110.     Call MsgBox("Sjekk at rett antall tags for diagnose er brukt")
  111.     Exit Sub
  112.  
  113.  
  114.  
  115.  
  116.  
  117. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement