Array not printing out beginning and end

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaAdmin
    New Member
    • Jan 2008
    • 3

    Array not printing out beginning and end

    This is a formula I am writing in Crystal Reports and vb is the closest thing to it so hopefully someone can figure this out.

    I am dealing with a long string that looks like 0.0055;0;0;0;0. It looks like an array but doesn;t act like on. For example, I only need the first value but if I ask for myArray[1], I get "0", myArray[2] yields ".", etc. So I created this for loop to get what I want:

    Code:
    numbervar i;
    stringvar str := "";
    
    for i := 1 to instr(1,{lt_mtg_ins.pmi-pymt-ftrs},";")-1 Do
    (
        str := str + {lt_mtg_ins.pmi-pymt-ftrs}[i];
        i := i + 1;
    );
    str
    Basically it starts at 1 and goes until the first semicolon. It adds each value to the end of the string until it is finished.

    Problem is for 0.0055;0;0;0;0, the resulting string is 005. Does anyone know what is going wrong here?
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    This code (vb6) will split (delimited with ";") the text from textbox "Text1" in an array "ARRtemp" and put the first string (index=0) in a textbox "Text2" = "0.0055".
    Code:
    Private Sub Command1_Click()
    Dim ARRtemp() As String ' array with splitted text
       ARRtemp = Split(Text1.Text, ";") 'split Text1.text on ";"
       Text2.Text = ARRtemp(0) ' put 1st string in textbox
    End Sub

    Comment

    • DaAdmin
      New Member
      • Jan 2008
      • 3

      #3
      I used your logic to figure it out, the answer in crystal would be simpler though,

      Code:
      stringvar array text;
      
      text := Split({lt_mtg_ins.pmi-pymt-ftrs}, ";");
      text[1]

      Comment

      Working...