Missing double quote after string - HELP!

  • Thread starter Thread starter Edward
  • Start date Start date
E

Edward

My function to populate fields on a form from a collection:

Private Sub cbfSetUpAddresses(ByVal pcolAddress As Collection)

Line 1 Me.txtAddress1.Text = pcolAddress(1).ToString
Line 2 Me.txtAddress2.Text = pcolAddress(2).ToString
Line 3 Me.txtAddress3.Text = pcolAddress(3).ToString
Line 4 Me.txtAddress4.Text = pcolAddress(4).ToString
Line 5 Me.txtPostCode.Text = pcolAddress(5).ToString

Line 6 End Sub

The Postcode text box is corrupted. As well as containing the correct
data it also contains a bunch of trailing stuff from another field.

If I look at these values in a Watch window, I notice the following:

At Line 1 in the function the value of Me.txtPostCode.Text = "GL5 4RT"
At Line 1 in the function the value of pcolAddress(5).ToString = "GL5
4RT"
At Line 6 in the function the value of Me.txtPostCode.Text = "GL5 4RT

NOTE THE MISSING " AT THE END.

The text box then displays:

GL5 4RTershire

Incidentally, the " is missing from all the populated text boxes, but
it only corrupts the display in the Postcode text box.

I tried this:

Dim strTemp As String = ""
strTemp = Trim(pcolAddress(5).ToString)
Me.txtPostCode.Text = strTemp.ToString

but it made no difference.

Clearly there are dark forces at work. Can anyone help?

TIA

Edward
 
* (e-mail address removed) (Edward) scripsit:
My function to populate fields on a form from a collection:

Private Sub cbfSetUpAddresses(ByVal pcolAddress As Collection)

Line 1 Me.txtAddress1.Text = pcolAddress(1).ToString
Line 2 Me.txtAddress2.Text = pcolAddress(2).ToString
Line 3 Me.txtAddress3.Text = pcolAddress(3).ToString
Line 4 Me.txtAddress4.Text = pcolAddress(4).ToString
Line 5 Me.txtPostCode.Text = pcolAddress(5).ToString

Line 6 End Sub

The Postcode text box is corrupted. As well as containing the correct
data it also contains a bunch of trailing stuff from another field.

If I look at these values in a Watch window, I notice the following:

At Line 1 in the function the value of Me.txtPostCode.Text = "GL5 4RT"
At Line 1 in the function the value of pcolAddress(5).ToString = "GL5
4RT"
At Line 6 in the function the value of Me.txtPostCode.Text = "GL5 4RT

NOTE THE MISSING " AT THE END.

The text box then displays:

Does that occur in a Windows Forms application? Maybe the string
contains a null character?
 
* (e-mail address removed) (Edward) scripsit: [...]
Does that occur in a Windows Forms application? Maybe the string
contains a null character?

No, it's an ASPX app.

You're quite right, of course. The function to obtain the string from
the Address finder software returns a string with TWO null characters.
VB then decides that the second one is the string terminator. I've
written a routine to get the "real" string out and it works a treat.

Thanks

Edward
 
Back
Top