473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Make Address Look Better

VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels. It
works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank space
in that area. Is there a way to make it so I can say if the data is empty,
temporarely delete the label or make it not exist at all? I'm not talking
about just hiding it because it still leaves an empy space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If
Oct 9 '07 #1
13 1429
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data is
empty, temporarely delete the label or make it not exist at all? I'm not
talking about just hiding it because it still leaves an empy space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If


Oct 9 '07 #2
What do I put in there so it will include a <BRto it's not all on the same
line? This is my new code and they all run together. I know how to put 1
space in between, but how do you put a return character?
CustAddr1L.Text = dr.Item("CustodianAddress1") &
dr.Item("CustodianAddress2") & dr.Item("CustodianAddress3")

"IfThenElse" <sq**********@hotmail.comwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
>VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data
is empty, temporarely delete the label or make it not exist at all? I'm
not talking about just hiding it because it still leaves an empy space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If



Oct 9 '07 #3
I'm using WebForm if that matters.
"IfThenElse" <sq**********@hotmail.comwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
>VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data
is empty, temporarely delete the label or make it not exist at all? I'm
not talking about just hiding it because it still leaves an empy space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If



Oct 9 '07 #4
On Oct 9, 7:00 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
What do I put in there so it will include a <BRto it's not all on the same
line? This is my new code and they all run together. I know how to put 1
space in between, but how do you put a return character?
CustAddr1L.Text = dr.Item("CustodianAddress1") &
dr.Item("CustodianAddress2") & dr.Item("CustodianAddress3")

"IfThenElse" <sql_agent...@hotmail.comwrote in message

news:er**************@TK2MSFTNGP05.phx.gbl...
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
VB.Net
I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data
is empty, temporarely delete the label or make it not exist at all? I'm
not talking about just hiding it because it still leaves an empy space.
This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP
This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP
Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then
CustAddr2L.Text = dr.Item("CustodianAddress2")
End If
If Not dr.Item("CustodianAddress3").ToString = String.Empty Then
CustAddr3L.Text = dr.Item("CustodianAddress3")
End If- Hide quoted text -

- Show quoted text -
if blank means null

CustAddr1L.Text = dr.Item("CustodianAddress1") _
& IsDBNull(dr.Item("CustodianAddress2"), "", "<br>" &
dr.Item("CustodianAddress2"))
& IsDBNull(dr.Item("CustodianAddress3"), "", "<br>" &
dr.Item("CustodianAddress3"))

Oct 9 '07 #5
Just put asp:Label controls on the WebForm where you will want the
appropriate content to go (using a table for presice layout is a great
idea). Then just pull out the data from your DataReader and put it into the
appropriate label. No need to fuss with <BRat all.
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OV**************@TK2MSFTNGP03.phx.gbl...
I'm using WebForm if that matters.
"IfThenElse" <sq**********@hotmail.comwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
>Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
>>VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data
is empty, temporarely delete the label or make it not exist at all? I'm
not talking about just hiding it because it still leaves an empy space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If




Oct 9 '07 #6
See my reply to pvong. Adding HTML <BRtags is sooooo Classic ASP. Use
labels instead.


"Alexey Smirnov" <al************@gmail.comwrote in message
news:11********************@o80g2000hse.googlegrou ps.com...
On Oct 9, 7:00 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
>What do I put in there so it will include a <BRto it's not all on the
same
line? This is my new code and they all run together. I know how to put
1
space in between, but how do you put a return character?
CustAddr1L.Text = dr.Item("CustodianAddress1") &
dr.Item("CustodianAddress2") & dr.Item("CustodianAddress3")

"IfThenElse" <sql_agent...@hotmail.comwrote in message

news:er**************@TK2MSFTNGP05.phx.gbl...
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
VB.Net
>I'm pulling Data from a DB and creating a letter by filling the
Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a
Blank
space in that area. Is there a way to make it so I can say if the
data
is empty, temporarely delete the label or make it not exist at all?
I'm
not talking about just hiding it because it still leaves an empy
space.
>This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP
>This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP
>Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then
>CustAddr2L.Text = dr.Item("CustodianAddress2")
>End If
>If Not dr.Item("CustodianAddress3").ToString = String.Empty Then
>CustAddr3L.Text = dr.Item("CustodianAddress3")
>End If- Hide quoted text -

- Show quoted text -

if blank means null

CustAddr1L.Text = dr.Item("CustodianAddress1") _
& IsDBNull(dr.Item("CustodianAddress2"), "", "<br>" &
dr.Item("CustodianAddress2"))
& IsDBNull(dr.Item("CustodianAddress3"), "", "<br>" &
dr.Item("CustodianAddress3"))

Oct 9 '07 #7
Scott, that's my problem to begin with. I do have labels and all the data
are flowing correctly, but it leaves a blank space where the Label is for
Address2 and 3 which is what I'm trying to avoid.

Can you take my code and show me how you would do it with multiple labels?
"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Just put asp:Label controls on the WebForm where you will want the
appropriate content to go (using a table for presice layout is a great
idea). Then just pull out the data from your DataReader and put it into
the appropriate label. No need to fuss with <BRat all.
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OV**************@TK2MSFTNGP03.phx.gbl...
>I'm using WebForm if that matters.
"IfThenElse" <sq**********@hotmail.comwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
>>Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
VB.Net

I'm pulling Data from a DB and creating a letter by filling the Labels.
It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank
space in that area. Is there a way to make it so I can say if the data
is empty, temporarely delete the label or make it not exist at all?
I'm not talking about just hiding it because it still leaves an empy
space.

This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP

This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP

Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then

CustAddr2L.Text = dr.Item("CustodianAddress2")

End If

If Not dr.Item("CustodianAddress3").ToString = String.Empty Then

CustAddr3L.Text = dr.Item("CustodianAddress3")

End If




Oct 9 '07 #8
On Oct 9, 8:04 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
Scott, that's my problem to begin with. I do have labels and all the data
are flowing correctly, but it leaves a blank space where the Label is for
Address2 and 3 which is what I'm trying to avoid.

Can you take my code and show me how you would do it with multiple labels?
The only thing you can do is to make an "empty" label invsible when it
has no text. It would help to make no empty line.

Oct 9 '07 #9
On Oct 9, 8:25 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 9, 8:04 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
Scott, that's my problem to begin with. I do have labels and all the data
are flowing correctly, but it leaves a blank space where the Label is for
Address2 and 3 which is what I'm trying to avoid.
Can you take my code and show me how you would do it with multiple labels?

The only thing you can do is to make an "empty" label invsible when it
has no text. It would help to make no empty line.
invsible = invisible

Oct 9 '07 #10
I tried your code:

CustAddr1L.Text = dr.Item("CustodianAddress1") &
IsDBNull(dr.Item("CustodianAddress2"), "", "
" & dr.Item("CustodianAddress2")) & IsDBNull(dr.Item("CustodianAddress3"),
"", "
" & dr.Item("CustodianAddress3"))

But I get the error message of:
Too Many Arguments to Public Funcion 'ISDBNULL(Expression As Object) As
Boolean'.
Oct 9 '07 #11
Just add if..then logic to hide the label if there is no data for it.

[psuedo code]

label2.visible = false
If Not IsDBNull(dr("itemName")) Then
label2.visible = true
label2.text = dr("itemName")
End If

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Scott, that's my problem to begin with. I do have labels and all the data
are flowing correctly, but it leaves a blank space where the Label is for
Address2 and 3 which is what I'm trying to avoid.

Can you take my code and show me how you would do it with multiple labels?
"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Just put asp:Label controls on the WebForm where you will want the
appropriate content to go (using a table for presice layout is a great
idea). Then just pull out the data from your DataReader and put it into
the appropriate label. No need to fuss with <BRat all.
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OV**************@TK2MSFTNGP03.phx.gbl...
>>I'm using WebForm if that matters.
"IfThenElse" <sq**********@hotmail.comwrote in message
news:er**************@TK2MSFTNGP05.phx.gbl...
Don't use CustAddr2L and CustAddr3L Just add everything to CustAddr1L
if CustAddr2L and CustAddr3L exit then add then to CustAddr1L
This way you don't need to remove anything.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:OD**************@TK2MSFTNGP02.phx.gbl...
VB.Net
>
I'm pulling Data from a DB and creating a letter by filling the
Labels. It works perfectly, but if Addr2 and Addr3 are blank, it
leaves a Blank space in that area. Is there a way to make it so I can
say if the data is empty, temporarely delete the label or make it not
exist at all? I'm not talking about just hiding it because it still
leaves an empy space.
>
This is what I get:
FirstName LastName
Addr1
Addr2 (this is blank if no data)
Addr3 (this is blank if no data)
City, State ZIP
>
This is what I want to get if Addr2 & Addr3 are blank:
FirstName LastName
Addr1
City, State ZIP
>
Here is my Code:
If Not dr.Item("CustodianAddress2").ToString = String.Empty Then
>
CustAddr2L.Text = dr.Item("CustodianAddress2")
>
End If
>
If Not dr.Item("CustodianAddress3").ToString = String.Empty Then
>
CustAddr3L.Text = dr.Item("CustodianAddress3")
>
End If
>
>




Oct 9 '07 #12
On Oct 9, 8:48 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
I tried your code:

CustAddr1L.Text = dr.Item("CustodianAddress1") &
IsDBNull(dr.Item("CustodianAddress2"), "", "
" & dr.Item("CustodianAddress2")) & IsDBNull(dr.Item("CustodianAddress3"),
"", "
" & dr.Item("CustodianAddress3"))

But I get the error message of:
Too Many Arguments to Public Funcion 'ISDBNULL(Expression As Object) As
Boolean'.
Sorry, I forgot about IIF

CustAddr1L.Text = dr.Item("CustodianAddress1") _
& Iif(IsDBNull(dr.Item("CustodianAddress2"), "", "<br>" &
dr.Item("CustodianAddress2")) _
& Iif(IsDBNull(dr.Item("CustodianAddress3"), "", "<br>" &
dr.Item("CustodianAddress3"))

The idea is just to check the value and if it equals to NULL return an
empty string.

It is an equivalent to

CustAddr1L.Text = dr.Item("CustodianAddress1")

If IsDBNull(dr.Item("CustodianAddress2") Then
CustAddr1L.Text &= ""
Else
CustAddr1L.Text &= "<br>" & dr.Item("CustodianAddress2"))
End If

If IsDBNull(dr.Item("CustodianAddress3") Then
CustAddr1L.Text &= ""
Else
CustAddr1L.Text &= "<br>" & dr.Item("CustodianAddress3"))
End If

or

CustAddr1L.Text = dr.Item("CustodianAddress1")

If Not IsDBNull(dr.Item("CustodianAddress2") Then CustAddr1L.Text &=
"<br>" & dr.Item("CustodianAddress2"))
If Not IsDBNull(dr.Item("CustodianAddress3") Then CustAddr1L.Text &=
"<br>" & dr.Item("CustodianAddress3"))

http://msdn2.microsoft.com/en-us/lib...0d(VS.80).aspx
http://msdn2.microsoft.com/en-us/lib...s5(VS.80).aspx

Oct 9 '07 #13
On Oct 9, 11:28 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 9, 8:48 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
I tried your code:
CustAddr1L.Text = dr.Item("CustodianAddress1") &
IsDBNull(dr.Item("CustodianAddress2"), "", "
" & dr.Item("CustodianAddress2")) & IsDBNull(dr.Item("CustodianAddress3"),
"", "
" & dr.Item("CustodianAddress3"))
But I get the error message of:
Too Many Arguments to Public Funcion 'ISDBNULL(Expression As Object) As
Boolean'.

Sorry, I forgot about IIF

CustAddr1L.Text = dr.Item("CustodianAddress1") _
& Iif(IsDBNull(dr.Item("CustodianAddress2"), "", "<br>" &
dr.Item("CustodianAddress2")) _
& Iif(IsDBNull(dr.Item("CustodianAddress3"), "", "<br>" &
dr.Item("CustodianAddress3"))
CustAddr1L.Text = dr.Item("CustodianAddress1") _
& Iif( IsDBNull(dr.Item("CustodianAddress2")) , "", "<br>" &
dr.Item("CustodianAddress2") ) _
& Iif( IsDBNull(dr.Item("CustodianAddress3")), "", "<br>" &
dr.Item("CustodianAddress3") )
Oct 9 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Bruce W...1 | last post by:
This is a best practices question. For a website where PHP is used, does it make sense to have both .htm and .php files? In other words, for pages that have no active content there's no point...
7
by: gurtd_dauberie | last post by:
I can't get the correct IP address on Linux... The following code works properly on Windows and Unix. But on Linux, I always get the Loopback Address (127.0.0.1) Here is the code : //gets the...
8
by: Maciej Wegorkiewicz | last post by:
Hi, I have small experience in XSLT processing and I have a problem which I cannot solve. Can you look at it? I have an input file containing info about bank accounts like this: (...) <acc...
12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
35
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
4
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
6
by: BA | last post by:
Hi Everyone, I have an application that sits behind a server farm, the application needs to pass its NLB IP address in the message that it sends to another service. From C# code, how can I...
11
by: timber910 | last post by:
hello all, I'm trying to figure out a good way to compare address across two tables. Example: Table 1 has the address of 12345 E Main St and table 2 has 12345 Main. I need to just look at the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.