dcsimg
Results 1 to 7 of 7

Thread: Help, creating errormsg (MSGBOX) when missing tag

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    4

    Help, creating errormsg (MSGBOX) when missing tag

    Hello dear friends.

    I am currently doing a school-project and I need some bad help. I have already created the correct code for putting the diagnosis and prescription. What i need help with is to create a correct errormessage IF a tag is missing an ending tag. Like if <diagnosis> starts before an earlier tag is finished.

    So the whole point is when the doctor types in <Diagnosis>Skiveprolaps</diagnosis>. It wil autmaitcally transfer to the diagnosis tab.Name:  1.jpg
Views: 176
Size:  16.3 KBName:  2.jpg
Views: 173
Size:  48.4 KBName:  3.jpg
Views: 172
Size:  9.1 KB

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,504

    Re: Help, creating errormsg (MSGBOX) when missing tag

    This appears to be VBA, rather than VB.NET. Therefore, I've moved the thread to the Office Development forum, which is the right place for VBA questions.

    In general, you should copy the code into the thread rather than posting a screen shot. Images get distorted in the forum, so screen shots of code are usually unreadable. That doesn't appear to be too much of an issue in this case, but a picture of the code is still harder to work with, as nobody can copy any of it as part of an answer.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    4

    Re: Help, creating errormsg (MSGBOX) when missing tag

    Option Compare Database
    Option Explicit

    Private Sub comDiagnose_Click()
    Dim i As Integer
    Dim diagnoser As Integer
    Dim resepter As Integer
    Dim start As Integer
    Dim slutt As Integer


    start = 0
    slutt = 0
    txtDiagnose = ""
    txtResept = ""

    For i = 1 To Len(txtJournal) - 9
    If Mid(txtJournal, i, 10) = "<diagnose>" Then
    start = i + 10
    ElseIf Mid(txtJournal, i, 11) = "</diagnose>" Then
    slutt = i
    txtDiagnose = txtDiagnose & Mid(txtJournal, start, slutt - start) & vbNewLine
    End If

    Next i
    For i = 1 To Len(txtJournal)
    If Mid(txtJournal, i, 8) = "<resept>" Then
    start = i + 8
    ElseIf Mid(txtJournal, i, 9) = "</resept>" Then
    slutt = i
    txtResept = txtResept & Mid(txtJournal, start, slutt - start) & vbNewLine
    ElseIf start <> 0 Then
    Call MsgBox("Missing tag") THIS IS where i need help...
    End If
    Exit For

    Next i
    End Sub

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Java (JSP) Hell!
    Posts
    5,303

    Re: Help, creating errormsg (MSGBOX) when missing tag

    Dont need Call
    What exactly do you need?
    Use the code tags ....

    Are you having more than one diagnosis and resept in your text?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    4

    Re: Help, creating errormsg (MSGBOX) when missing tag

    Hello

    I need to create a tool (which pops up in a messagebox), the tool should give an error if a tag is missing.
    Example:
    <diagnosis> is the start, </diagnosis> is the end on the code, and in the middle the diagnosis is typed. What I need to create is an error that pops up when the starting tag comes up before the endingtag. Like this:
    <diagnosis>Headache<diagnosis>.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,783

    Re: Help, creating errormsg (MSGBOX) when missing tag

    what is happening with the msgbox now?


    when the doctor types in <Diagnosis>Skiveprolaps</diagnosis>. It wil autmaitcally transfer to
    if you want it to transfer automatically you could have code in the keypress (or keyup) event of the textbox to check if an end tag has been just been typed

    i would use instr to test for start and finish tags, rather than the loop
    Code:
    start = instr(txtJournal, "<resept>") + 8
    if start >0 then
      slutt = instr(start, txtJournal, "</resept>")
      if slutt > 0 then
        txtResept = txtResept & Mid(txtJournal, start, slutt - start) & vbNewLine
        else
         msgbox "Missing tag"
      end if
    end if
    Not tested
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    409

    Re: Help, creating errormsg (MSGBOX) when missing tag

    Since it is a school project, it is unclear if you are simply writing code given a rigid set of requirements, or if you have leeway of how the code functions.

    I can say from experience working with many Doctors over the years, no doctor anywhere will tolerate using software that requires that they enclose a diagnosis inside of manually typed XML tags. So, unless that is a specific requirement of your program based on the assignment, I would recommend that you come up with a less stringent solution.

    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width