Home All Groups Group Topic Archive Search About
Author
19 Nov 2007 5:34 PM
thomas1388@gmail.com
I am created a form to display addresses.  There are 5 fields, street,
street line 2, city , state and zip code.  If there is street line 2,
it will become my address line 2, City & ", " * state & zip will
become my address line 3.  Since some of the addresses don't have
street line 2, I like to make City & ", " * state & zip as my address
line 2, the address line 3 will become invisible.

After I binded a dataset in the data source window, I dragged a field
into the form, the label control is data-bounced to the field.  I have
tried to do the task with the following code:

        If lblStreetLine2.Text = String.Empty Then
            lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
                Trim(lblState.Text) & " " & lblZip.Text
            lblAddressLine3.Text = String.Empty
            lblAddressLine3.Visible = False
        Else
            lblAddressLine2.Text = lblStreetLine2.Text
            lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
                Trim(lblState.Text) & " " & lblZip.Text
            lblAddressLine3.Visible = true
        End If

It didn't work.  Can anyone help me?  Thank you.

Author
19 Nov 2007 6:44 PM
Terry
Well, you have me confused!  When you say the labels are bound, which labels?
I am guessing that you bound the DataSource to 5 labels (invisible?) and
then are trying to display the three (different) Address labels depending on
the contents of the 5 bound labels.  Am I close?  While there is no reason to
do the binding to the 5 labels, I don't see why it wouldn't work.  So, where
did you put the code that you showed?  Sounds like it should be in your
BindingSource PositionChanged event handler. Is it?
When you say it didn't work - well can you be more specific?
--
Terry


Show quoteHide quote
"thomas1***@gmail.com" wrote:

> I am created a form to display addresses.  There are 5 fields, street,
> street line 2, city , state and zip code.  If there is street line 2,
> it will become my address line 2, City & ", " * state & zip will
> become my address line 3.  Since some of the addresses don't have
> street line 2, I like to make City & ", " * state & zip as my address
> line 2, the address line 3 will become invisible.
>
> After I binded a dataset in the data source window, I dragged a field
> into the form, the label control is data-bounced to the field.  I have
> tried to do the task with the following code:
>
>         If lblStreetLine2.Text = String.Empty Then
>             lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
>                 Trim(lblState.Text) & " " & lblZip.Text
>             lblAddressLine3.Text = String.Empty
>             lblAddressLine3.Visible = False
>         Else
>             lblAddressLine2.Text = lblStreetLine2.Text
>             lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
>                 Trim(lblState.Text) & " " & lblZip.Text
>             lblAddressLine3.Visible = true
>         End If
>
> It didn't work.  Can anyone help me?  Thank you.
>
Author
19 Nov 2007 6:44 PM
Jack Jackson
On Mon, 19 Nov 2007 09:34:17 -0800 (PST), "thomas1***@gmail.com"
<thomas1***@gmail.com> wrote:

Show quoteHide quote
>I am created a form to display addresses.  There are 5 fields, street,
>street line 2, city , state and zip code.  If there is street line 2,
>it will become my address line 2, City & ", " * state & zip will
>become my address line 3.  Since some of the addresses don't have
>street line 2, I like to make City & ", " * state & zip as my address
>line 2, the address line 3 will become invisible.
>
>After I binded a dataset in the data source window, I dragged a field
>into the form, the label control is data-bounced to the field.  I have
>tried to do the task with the following code:
>
>        If lblStreetLine2.Text = String.Empty Then
>            lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
>                Trim(lblState.Text) & " " & lblZip.Text
>            lblAddressLine3.Text = String.Empty
>            lblAddressLine3.Visible = False
>        Else
>            lblAddressLine2.Text = lblStreetLine2.Text
>            lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
>                Trim(lblState.Text) & " " & lblZip.Text
>            lblAddressLine3.Visible = true
>        End If
>
>It didn't work.  Can anyone help me?  Thank you.

It is not helpful to us to say "It didn't work".

What did it do, and how is that different from what you expected?
Author
19 Nov 2007 7:17 PM
thomas1388@gmail.com
On Nov 19, 1:44 pm, Jack Jackson <jacknos***@pebbleridge.com> wrote:
Show quoteHide quote
> On Mon, 19 Nov 2007 09:34:17 -0800 (PST), "thomas1***@gmail.com"
>
>
>
> <thomas1***@gmail.com> wrote:
> >I am created a form to display addresses.  There are 5 fields, street,
> >street line 2, city , state and zip code.  If there is street line 2,
> >it will become my address line 2, City & ", " * state & zip will
> >become my address line 3.  Since some of the addresses don't have
> >street line 2, I like to make City & ", " * state & zip as my address
> >line 2, the address line 3 will become invisible.
>
> >After I binded a dataset in the data source window, I dragged a field
> >into the form, the label control is data-bounced to the field.  I have
> >tried to do the task with the following code:
>
> >        If lblStreetLine2.Text = String.Empty Then
> >            lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
> >                Trim(lblState.Text) & " " & lblZip.Text
> >            lblAddressLine3.Text = String.Empty
> >            lblAddressLine3.Visible = False
> >        Else
> >            lblAddressLine2.Text = lblStreetLine2.Text
> >            lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
> >                Trim(lblState.Text) & " " & lblZip.Text
> >            lblAddressLine3.Visible = true
> >        End If
>
> >It didn't work.  Can anyone help me?  Thank you.
>
> It is not helpful to us to say "It didn't work".
>
> What did it do, and how is that different from what you expected?

In my table, there are 5 fields, street, street line 2, city, state
and zip.  After I dragged those fields into the form, I named them
lblStreet, lblStreetLine2, lblCity, lblState and lblZip.  The lblSteet
label control is data-bounced to the Street field, so it displays the
street of the the person selected in the list box.  I could also
display street line 2 , city, state and zip the same way but I want to
do it fancier.  If the street line 2 is empty, I want to make City &
", " * state & zip as my address
line 2, the address line 3 will become invisible.  If street line 2 is
not null, then the address line 2 will display street line 2 and the
address line 3 will display City & ", " * state & zip.  My codes are:

If lblStreetLine2.Text = String.Empty Then
    lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
    Trim(lblState.Text) & " " & lblZip.Text
    lblAddressLine3.Text = String.Empty
Else
    lblAddressLine2.Text = lblStreetLine2.Text
    lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
    Trim(lblState.Text) & " " & lblZip.Text
    lblAddressLine3.Visible = true
End

When I run the program, the address line 2 and address line 3 return
sting empty.  It doesn't matter if the street line 2 is string.empty
or not.  I believe that lblCity.text, lblState.text and lblZip.text
are equal null in the program.  They should not.

Please feel free to ask me if you need any additional clarification.
Thank all of you for your help.
Author
19 Nov 2007 10:21 PM
Terry
>I believe that lblCity.text, lblState.text and lblZip.text
are equal null in the program.  They should not.

You don't know?  Why don't you set a breakpoint and find out?  If they are
all empty, then it has nothing to do with the code you included here.  It is
in the binding logic somewhere.  You mention a listbox, bound to a
BindingSource?  Same BindingSource used by the labels?  And I asked before
and will ask again, where is the code you  have included?  In what event
handler?

--
Terry


Show quoteHide quote
"thomas1***@gmail.com" wrote:

> On Nov 19, 1:44 pm, Jack Jackson <jacknos***@pebbleridge.com> wrote:
> > On Mon, 19 Nov 2007 09:34:17 -0800 (PST), "thomas1***@gmail.com"
> >
> >
> >
> > <thomas1***@gmail.com> wrote:
> > >I am created a form to display addresses.  There are 5 fields, street,
> > >street line 2, city , state and zip code.  If there is street line 2,
> > >it will become my address line 2, City & ", " * state & zip will
> > >become my address line 3.  Since some of the addresses don't have
> > >street line 2, I like to make City & ", " * state & zip as my address
> > >line 2, the address line 3 will become invisible.
> >
> > >After I binded a dataset in the data source window, I dragged a field
> > >into the form, the label control is data-bounced to the field.  I have
> > >tried to do the task with the following code:
> >
> > >        If lblStreetLine2.Text = String.Empty Then
> > >            lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
> > >                Trim(lblState.Text) & " " & lblZip.Text
> > >            lblAddressLine3.Text = String.Empty
> > >            lblAddressLine3.Visible = False
> > >        Else
> > >            lblAddressLine2.Text = lblStreetLine2.Text
> > >            lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
> > >                Trim(lblState.Text) & " " & lblZip.Text
> > >            lblAddressLine3.Visible = true
> > >        End If
> >
> > >It didn't work.  Can anyone help me?  Thank you.
> >
> > It is not helpful to us to say "It didn't work".
> >
> > What did it do, and how is that different from what you expected?
>
> In my table, there are 5 fields, street, street line 2, city, state
> and zip.  After I dragged those fields into the form, I named them
> lblStreet, lblStreetLine2, lblCity, lblState and lblZip.  The lblSteet
> label control is data-bounced to the Street field, so it displays the
> street of the the person selected in the list box.  I could also
> display street line 2 , city, state and zip the same way but I want to
> do it fancier.  If the street line 2 is empty, I want to make City &
> ", " * state & zip as my address
> line 2, the address line 3 will become invisible.  If street line 2 is
> not null, then the address line 2 will display street line 2 and the
> address line 3 will display City & ", " * state & zip.  My codes are:
>
> If lblStreetLine2.Text = String.Empty Then
>     lblAddressLine2.Text = Trim(lblCity.Text) & ", " & _
>     Trim(lblState.Text) & " " & lblZip.Text
>     lblAddressLine3.Text = String.Empty
> Else
>     lblAddressLine2.Text = lblStreetLine2.Text
>     lblAddressLine3.Text = Trim(lblCity.Text) & ", " & _
>     Trim(lblState.Text) & " " & lblZip.Text
>     lblAddressLine3.Visible = true
> End
>
> When I run the program, the address line 2 and address line 3 return
> sting empty.  It doesn't matter if the street line 2 is string.empty
> or not.  I believe that lblCity.text, lblState.text and lblZip.text
> are equal null in the program.  They should not.
>
> Please feel free to ask me if you need any additional clarification.
> Thank all of you for your help.
>
>