Solved

lable text syntax

Posted on 2006-06-21
2
184 Views
Last Modified: 2010-04-23
I have a lable (lblPathway) I wanted added to an existing windows form.

I want the lable to read what is pulled over by a dataadapter.

I've created a dataset from this adapter (dsPathway) and it contains two fields

fieldA, fieldB


If fieldA = 1(it's a bit 1 or 0) then I want it to display some text and a FieldB. else I want to display only fieldB.


so  something like   If dsPathway.fieldA = '1' then  lblPathway = "IMG + dspathway.fieldb.text"  Else lblPathway = DsPathway.text

so does this look correct?  do I need a function?

Thanks in advance.

Is this syntax correct?



0
Comment
Question by:TimSweet220
  • 2
2 Comments
 
LVL 20

Expert Comment

by:ElrondCT
ID: 16955355
You need to assign the desired value to lblPathway.Text, not just lblPathway. On the other hand, fieldB most likely wouldn't have a .Text designation; the field itself is simply a text item. If fieldA is a numeric field, you wouldn't put quotes around it when you're doing the comparison.

So your code would probably be more like:

If dsPathway.fieldA = 1 Then
   lblPathway.Text = "IMG" & dsPathway.fieldB
Else
   lblPathway.Text = dsPathway.fieldB
End If
0
 
LVL 20

Accepted Solution

by:
ElrondCT earned 500 total points
ID: 16955378
The key to whether fieldA references need to be in quotes is whether or not the field is defined as numeric, not whether it has numbers in it. If it's defined as a string (text) but the text is all numbers, you'll need to put a quote around "1"; if the database definition is of a numeric datatype, you wouldn't use the quotes. VB's Intellisense will tell you which is correct.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now