473,378 Members | 1,467 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,378 software developers and data experts.

Problem Setting radio buttons based on data value

I'm trying to set a group of radio buttons based on the value of a
text field in a dataset. This is my code:

Dim ds As DataSet
ds = dtsVideo
Dim dt As DataTable = ds.Tables("tblPeramItems")
Dim dr As DataRow = dt.Rows(0) 'first row in datatable

If dr("strStockGroup") = "DVD" Then
rdbDVD.Checked = True
ElseIf dr("strStockGroup") = "Video" Then
rdbVideo.Checked = True
ElseIf dr("strStockGroup") = "Computer Game" Then
rdbComputerGame.Checked = True
End If

This works as long as I have "Option Strict" set to "Off". Otherwise
i get the error "Option strict on disallows operands of type object
for operator '='.
Use the 'Is' operator to test for object Identity"

Unfortunately I am required to have "Option Strict" set to "ON". Any
ideas on how I can make this work?

Greg
Jul 17 '05 #1
2 4052
"Greg" <gr******@tpg.com.au> skrev i en meddelelse
news:c2**************************@posting.google.c om...
I'm trying to set a group of radio buttons based on the value of a
text field in a dataset. This is my code:

Dim ds As DataSet
ds = dtsVideo
Dim dt As DataTable = ds.Tables("tblPeramItems")
Dim dr As DataRow = dt.Rows(0) 'first row in datatable

If dr("strStockGroup") = "DVD" Then
rdbDVD.Checked = True
ElseIf dr("strStockGroup") = "Video" Then
rdbVideo.Checked = True
ElseIf dr("strStockGroup") = "Computer Game" Then
rdbComputerGame.Checked = True
End If
A better way to make this is :

Select Case LCase(dr("strStockGroup")) ' LCase makes it lowercase
Case "dvd"
rdbDVD.Checked = True
Case "video"
rdbVideo.Checked = True
Case "computer game"
rdbComputerGame.Checked = True
End Select

This works as long as I have "Option Strict" set to "Off". Otherwise
i get the error "Option strict on disallows operands of type object
for operator '='.
Use the 'Is' operator to test for object Identity"

Unfortunately I am required to have "Option Strict" set to "ON". Any
ideas on how I can make this work?

Greg

Jul 17 '05 #2
Replace If dr("strStockGroup") = "DVD" Then
with If dr("strStockGroup").ToString = "DVD" Then

Option Strict On requires all datatypes are consistent - so you must tell
..NET that the data from your row is a string.

As I've seen mentioned many many times in this group, your post should be
sent to .NET forums, not this VB6 forum.
__________________________________________
The Grim Reaper

"Greg" <gr******@tpg.com.au> wrote in message
news:c2**************************@posting.google.c om...
I'm trying to set a group of radio buttons based on the value of a
text field in a dataset. This is my code:

Dim ds As DataSet
ds = dtsVideo
Dim dt As DataTable = ds.Tables("tblPeramItems")
Dim dr As DataRow = dt.Rows(0) 'first row in datatable

If dr("strStockGroup") = "DVD" Then
rdbDVD.Checked = True
ElseIf dr("strStockGroup") = "Video" Then
rdbVideo.Checked = True
ElseIf dr("strStockGroup") = "Computer Game" Then
rdbComputerGame.Checked = True
End If

This works as long as I have "Option Strict" set to "Off". Otherwise
i get the error "Option strict on disallows operands of type object
for operator '='.
Use the 'Is' operator to test for object Identity"

Unfortunately I am required to have "Option Strict" set to "ON". Any
ideas on how I can make this work?

Greg

Jul 17 '05 #3

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

Similar topics

3
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
1
by: Jim Quast | last post by:
I have an ASP page and a CREGReports002.vbs file coded to export data to excel. I do this by building variables in a stored procedure. The ASP page has text boxes, list boxes, and radio buttons. ...
15
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
3
by: rob c | last post by:
Hi I'm not sure if this is the right place to ask for help on forms and radio buttons... In the following form, I'd like to set the value of 'item_name' based on which radio button was...
1
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
1
by: FunkHouse9 | last post by:
I'm trying to develop an order page and in one section, the customer specifies a shipment type using radio buttons that is submitted to the shopping cart. There are 4 buttons. If either of the...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...

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.