Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Array trouble

Array trouble

Scheduled Pinned Locked Moved Visual Basic
questionhelpdatabasedata-structures
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tatchung
    wrote on last edited by
    #1

    Hello, I'm creating a parser for some logs derived from ssh. I used an array to split the logs for every "next line" I encounter then I have to go through all those lines again (one by one) to check for certain keywords. My problem is after going through the 1st index, the 2nd index acquires a "next line" at the beginning meaning my search can't function accurately. My question is how do I remove that line at the beginning of my 2nd index? I've tried TRIM and REPLACE but none of it doesn't seem to work. Many thanks for any help you could give me. :) Oh by the way I'm prehistoric...this is done in vb6 :) Here's my code:

    a = txtSam.Text
    strarray = Split(a, Chr(13))
    For b = 0 To 3
    strarray(b) = Replace(strarray(b), Chr(13), "")
    strarray(b) = Trim(strarray(b))
    If Mid(strarray(b), 21, 4) = "[15]" Then
    pos1 = InStr(1, strarray(b), "<")
    strurl = Mid(strarray(b), pos1)
    strurl = Replace(strurl, "<", "")
    strurl = Replace(strurl, ">", "")
    strurl = Trim(strurl)
    ElseIf Mid(strarray(b), 21, 4) = "Sent" Then
    pos1 = InStr(1, strarray(b), "[msg")
    pos2 = InStr(1, strarray(b), "[udh")
    str1 = Mid(a, pos1, pos2 - pos1)
    str1 = Replace(str1, "[msg:", "")
    str1 = Trim(str1)
    str1 = Mid(str1, InStr(1, str1, ":") + 1)
    str1 = StrReverse(str1)
    str1 = Mid(str1, 2)
    str1 = StrReverse(str1)
    End If
    Next b

    Aim small, miss small

    P 1 Reply Last reply
    0
    • T tatchung

      Hello, I'm creating a parser for some logs derived from ssh. I used an array to split the logs for every "next line" I encounter then I have to go through all those lines again (one by one) to check for certain keywords. My problem is after going through the 1st index, the 2nd index acquires a "next line" at the beginning meaning my search can't function accurately. My question is how do I remove that line at the beginning of my 2nd index? I've tried TRIM and REPLACE but none of it doesn't seem to work. Many thanks for any help you could give me. :) Oh by the way I'm prehistoric...this is done in vb6 :) Here's my code:

      a = txtSam.Text
      strarray = Split(a, Chr(13))
      For b = 0 To 3
      strarray(b) = Replace(strarray(b), Chr(13), "")
      strarray(b) = Trim(strarray(b))
      If Mid(strarray(b), 21, 4) = "[15]" Then
      pos1 = InStr(1, strarray(b), "<")
      strurl = Mid(strarray(b), pos1)
      strurl = Replace(strurl, "<", "")
      strurl = Replace(strurl, ">", "")
      strurl = Trim(strurl)
      ElseIf Mid(strarray(b), 21, 4) = "Sent" Then
      pos1 = InStr(1, strarray(b), "[msg")
      pos2 = InStr(1, strarray(b), "[udh")
      str1 = Mid(a, pos1, pos2 - pos1)
      str1 = Replace(str1, "[msg:", "")
      str1 = Trim(str1)
      str1 = Mid(str1, InStr(1, str1, ":") + 1)
      str1 = StrReverse(str1)
      str1 = Mid(str1, 2)
      str1 = StrReverse(str1)
      End If
      Next b

      Aim small, miss small

      P Offline
      P Offline
      paas
      wrote on last edited by
      #2

      You probably also need to remove the newline character. So, after removing the carriage return character, do a replace to remove the newline character. Those two lines of code will look like...

      strarray(b) = Replace(strarray(b), Chr(13), "")
      strarray(b) = Replace(strarray(b), Chr(10), "")

      Hopefully that will do the trick for you...

      T 1 Reply Last reply
      0
      • P paas

        You probably also need to remove the newline character. So, after removing the carriage return character, do a replace to remove the newline character. Those two lines of code will look like...

        strarray(b) = Replace(strarray(b), Chr(13), "")
        strarray(b) = Replace(strarray(b), Chr(10), "")

        Hopefully that will do the trick for you...

        T Offline
        T Offline
        tatchung
        wrote on last edited by
        #3

        This forum never ceases to amaze me. Works perfectly. Many thanks for the help friend! :-D

        Aim small, miss small

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups