TomW 73 Posting Whiz
Private Sub btnclearall_Click

Dim ctl As New Control

For Each ctl In Me.Controls
Next

'Ok above you looped through all controls on your form but did
'nothing with each itteration

'Now below is only checking one single control, the last one of your form
If Typeof ctl Is textbox Then

    'Above you detemined ctl, is a texbox, so why are
    'you creating a new text box and converting the 
    'the existing textbox into another textbox?
    Dim txtcontrol As Textbox = Directcast (ctl.Textbox)


    'Me is the form you are in, so the only thing
    'you are changing is the text propert of the form itself
    'not any of the text boxes.
    Me.text = StringEmpty

See Rogachev's post above which shows how to correctly itterate thru the controls and clear the textboxes as it goes. But as an additional note, the coding provided will not itterate thru child controls within a container control. For example if you have a few panels and/or group boxes you would need to itterate thru each seperatly to find each of the child controls.

TomW 73 Posting Whiz

You need to be storing these individual values into numeric variables to be calculated at the end.

'Radio Choice
Selection

Dim decRadioPrice As Decimal

        Console.WriteLine("Please enter the Radio Choice for your vehicle: ")
        Console.WriteLine("Enter 1 for AM/FM Radio")
        Console.WriteLine("Enter 2 for AM/FM/CD/DVD")
        strRadioChoice = Console.ReadLine()
        Select Case strRadioChoice
            Case "1"
                Console.WriteLine("Price : $100")
                decRadioPrice = 100.00
            Case "2"
                Console.WriteLine("Price : $400")
                 decRadioPrice = 400.00
            Case Else
                Console.WriteLine("Invalid selection")

        End Select

        'SellingPrice = BasePrice + strEngineChoice + strInteriorChoice 
        '+ strRadioChoice + ShippingCharge + DealerCharge
 
         decTotal = decBasePrice + desEnginePrice + decInterior + decRadio etc
        Console.WriteLine("The total selling price for your vehicle is $" + FormatCurrencty(decTotal))
        Console.WriteLine()
        Console.WriteLine("Press Enter to Exit")
        Console.ReadLine()
JRabbit2307 commented: thanks this solved it! +1
TomW 73 Posting Whiz

I dont understand the need for a loop to assign control values when only a single value can be displayed in the textbox and datepicker at a time. Also Im a bit confused by the naming conventions, a prefix for txt for a datepicker and your saying your looking for a date but the select statement shows your querying a field named "Name".

TomW 73 Posting Whiz

This is a console app or is that just for your example? If a console app, I would start by displaying a list of the choices they have to pick from with an item/row number starting each line and then asking for them to type that item/row number in for the input. Also remember what is read/written is already text even if there writing a number...

Dim strEngineChoice As String = ""

        Console.WriteLine("Enter 1 for six cylinder")
        Console.WriteLine("Enter 2 for eight cylinder")
        Console.WriteLine("Enter 3 for disel")

        strEngineChoice = Console.ReadLine

        Select Case strEngineChoice
            Case "1"
                Console.WriteLine("Price : $150")
            Case "2"
                Console.WriteLine("Price : $475")
            Case "3"
                Console.WriteLine("Price : $750")
            Case Else
                Console.WriteLine("Invalid selection")
        End Select
TomW 73 Posting Whiz

The problem with the above statement is this loop will run constantly looking for this new value. You could change this to a timer event where you can set the interval of how often it checks to see if the value has change but again this is something that will run in the background until it either finds the changed value or is explicitily coded to turn off. I prefer not to have things such as this run in the background whenever possibile (although sometimes it may be unavoidable). I'm not sure what your app is doing but if possible I would suggest something where the user clicks a control on your form when there ready to get/save the changes.

TomW 73 Posting Whiz

Also I wanted to add my above example would remove the record from the database but not from your already filled dataset/datatable. In that case you have atleast 3 choices, 1) refill your table afterwards, 2) manually remove the record from the datatable too and call acceptchanges, or 03) (best choice) assign the above delete command object to your DataAdapter.DeleteCommand and then when you remove the record from your in memory datatable and call your dataadapter.update method all will be synchronized.

TomW 73 Posting Whiz

I agree calling a stored procedure to first delete your child records & then the parent is the way to go. However I would suggest not calling "exec" thru a regular query statement; this causes unneccesary processing by the database, it forces the database to first parse the info and then build the SP anyway; additionally concatenating filter values in the query string rather then using a parameter is not the best choice as kplcjl has already pointed out.

To properly call a stored procedure is just as easy although many dont seem familar with it. Create your command object and set a few extra properties. Set the CommandType to StoredProcedure (default is Text) and add your parameter.

Using con As New SqlConnection(strMyConnectionString)
            Dim cmdDelete As New SqlCommand

            With cmdDelete
                .Connection = con
                .CommandType = CommandType.StoredProcedure
                .CommandText = "myStoredProcedureName"
                .Parameters.AddWithValue("@CustId", CInt(id))
                .ExecuteNonQuery()
                .Dispose()
            End With 'cmdDelete
        End Using 'con

The above was based on SQL Server but will also work for other databases by changing to the proper namespaces.

TomW 73 Posting Whiz
If TextBox1.Text.ToLower = User.ToLower And TextBox2.Text.ToLower = "it" Then
TomW 73 Posting Whiz

Ok first, you dont need to explictily call open and close to your database connection, your dataadapter will open & close the connection as needed.

Your error is being caused by your concatenated query string. Your connection object is actually within your query double quotes becoming part of the select statement rather then being passed as the second parameter for the connection.

TomW 73 Posting Whiz

If you use the Code icon at the text area toolbar it will format your code for easier understanding here on the site.

Im not sure why your closing your connection before you even open it but either way both open & close calls are not needed. When you use a DataAdapter, it will automatically open & close the connection when you call the fill or update methods.

With Access you want to enclose your dates with the # symbol as you would quotes for strings. Since this is a date I would also suggest converting the text value of the textbox to an actual Date datatype. However I would suggest not concatenating your query string and instead use Parameter's to pass your value.

TomW 73 Posting Whiz

As for suggestions on how to handle this, I guess a lot depends on whether this particular datatable is going to update existing records or insert new records back to your database? You dont want to overwrite your existing default dates with null values. If this is going to be a read only display (not updating or inserting the dv) it wont matter if you change the values in the datatable. However if you will be updating this datasource you want to take care not to lose those original default dates and/or replace them back before updating your db.

My suggestion would be to have two columns, one which is your datatime column holding the true values but hidden from the user and an additional (new) column that displays a string formatted representation of those dates for the user.

TomW 73 Posting Whiz

I seem to have answered your post question but not in regards to the thread title. A DataGridView is a control that provides a way to display the data of its underlying datasource. You should think of a DGV as a viewer and always work with the actual data which is the actual datasource (datatable).

TomW 73 Posting Whiz

Take a look at "FileMode" in the help index. Your use of FileMode.Create will always create a new file including overwriting the file if it already exists. Instead you want to create a file if it doesnt exist but append to a file if it does exist.

TomW 73 Posting Whiz

You can set the datetime column of the datatable to allow nulls but it wont accept blank strings. However I suggest that leaving a default date is good practice, filtering such as in a where clause on or against null values prevents the benefits of table indexing.

TomW 73 Posting Whiz

The DataGridView control is simply a means of displaying data from an underlying datasource such as a DataSet/DataTable/Array etc.... You do not want to add rows directly to the DataGridView, you want to add rows to the underlying datasource. Such as if you have a datatable attached, it is the datatable you want to add a row too.

TomW 73 Posting Whiz

Short answer is Yes. Are you familar with retrieving database data and what exactly are you returning, a single value or many records that corrospond with a specific date?

TomW 73 Posting Whiz

Either way you need to pass the info back to the main form... I dont know where your getting the value of $895 from or how your calculating it but the below example shows how to pass the selected listbox item back to the main form.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim frm As New Form2
        Dim strListItem As String = ""

        Me.Visible = False
        frm.ShowDialog()

        If frm.CheckBox1.Checked = True And frm.CheckBox2.Checked = True Then
            MessageBox.Show("Both checkboxes were checked")

            If frm.ListBox1.SelectedIndex > -1 Then
                strListItem = frm.ListBox1.SelectedItem.ToString
                Messagebox.Show(strListItem)
            End If
        Else
            MessageBox.Show("Both checkboxes were not checked")
        End If

        frm.Dispose()

    End Sub

End Class
TomW 73 Posting Whiz

You can create report parameters where the user would have to select a date before the report opens up. Personally I would do all this sort of stuff on the front end in the VB app and only fill your dataset with the info you want passed to the report. But yes, if you want to discuss this further it probably should be its own thread.

TomW 73 Posting Whiz

Oh the My.Settings is not something available in 03.

TomW 73 Posting Whiz

If you set Option Strict & Option Explict to On you would see many errors within this example. Besides the variable "Name" all other variables are numeric but you are assigning text values to them without first converting them to a numeric value. Remember textboxes hold text, even if a number is displayed within it, the program still see's it as text.

IE:

intAge = CInt(txtAge.Text)  'This will convert your text value to an integer
TomW 73 Posting Whiz

Plenty of info about saving and reading saved settings in the help file, just type My.Settings in the help index. To sum it up you can create setting in the window I previously mentioned, you need to create a name for each setting, set its datatype, scope and value. However you mentioned that a wizard already created this setting for you. To use/change the setting you need to determine what the setting name is.

TomW 73 Posting Whiz

My above example should show you how to determine if the two checkboxes were selected; just replace the checkbox names with the names of your checkboxes. What information do you need returned from the listbox (the selected item text, selected index, a hidden value member value)? Also is the listbox set to allow more then one item to be selected at a time? Can you provide an example of the data/items filled in the listbox?

Validation should be done (when possibile) in a single location. Such as if a user is still clicking options (ie checkboxes) this may not be the best spot to do it rather then when he clicks an Ok/Save type button you can check all validation at once. This can be done on either form, frmMain or your options form. I would probably do it when they clicked the OK button that closes the options form this way if they do need to select something else that dont have to re-open the form. Two reasons that I can think of you may not want to do this though, first I dont know what else the form may used for; for example is selecting a different class neccesarily wrong in all cases of using this form and second is simply that you may be required to show that all this info can be passed back to the main form, in which case I would do as soon as the form is closed but before it is …

TomW 73 Posting Whiz

I was rereading your original post, again its a bit confusing since you mention two checkboxes but them mention something about a list (listbox?) also your checking for text and numeric values that have nothing to do with checkboxes.

But going by the assumption that your only checking to see if two check boxes were checked on a second form, here is an example.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim frm As New Form2
        frm.ShowDialog()

        If frm.CheckBox1.Checked = True And frm.CheckBox2.Checked = True Then
            MessageBox.Show("Both checkboxes were checked")
        Else
            MessageBox.Show("Both checkboxes were not checked")
        End If

        frm.Dispose()

    End Sub

End Class
TomW 73 Posting Whiz

That error msg states you are converting a blank string into a double... Apparently whatever your doing is text and has no value at all.

TomW 73 Posting Whiz

Ok first, what numeric value are you attempting to check for and what value in lstWorkships (listbox?) are you trying to get? I thought you mentioned this was a checkbox but your checking for a text value and seeing if it has a numeric value within it, so im a bit confused.

Also there are many ways of passing values between forms (public properties, public/global variables etc), I dont want to suggest something not specific to where your at in class. Can you provide your two forms?

TomW 73 Posting Whiz

I showed you how to take your trackbar value that you were saving; calculate it and use the new value to assign to your opacity property. I have no clue how you are attempting to save/load a seperate setting since that wasnt discussed.

TomW 73 Posting Whiz

In your project properties you will see a settings tab, find out the name of your connection string setting. In coding you simply change it by assigning it a new value

My.Settings.ConnectionString1 = strMyNewConnectionStringVariable

If you need help with how to create a connection string, I can provide more info.

TomW 73 Posting Whiz

Again to get the value within the NumericUpDown you simply access the value property.

Label1.Text = NumericUpDown1.Value.ToString

I have no clue or understanding why you are attempting to keep changing its value in the value changed event but I know it will cause a recursive problem being every time the user changes a value it will trigger that event which iteself keeps changing its value causing it to also keep triggering.... I also have no clue why your trying to manually make it click the event in a loop. If you need it to be a different value, then simply change its value.

NumericUpDown1.Value = XX.XX 'Whatever value you want

Im sorry I cant be of more help but I simply dont understand what your trying to accomplish.

TomW 73 Posting Whiz

I'm still not following you. You dont need to implement any code to have the value increase when clicking on the arrow keys, you can do that right in the property window by setting the increment property. And you dont need to itterate thru a loop or count how many times its been clicked to get the value, simply accessing its value property will tell you its current value.

MessageBox.Show(NumericUpDown1.Value.ToString)

TomW 73 Posting Whiz

c'mon now..... there is no division by 100 if you have 10 as a max value. Instead you multplie by one tenth.

Me.Opacity = My.Settings.TaxiTransparency * 0.1

xfrolox commented: Thx you got a reputation for helping me +1
TomW 73 Posting Whiz

I get it just fine.... 5 is not going to change the opacity level of your form, you need to convert it so that the opacity is 0.5

TomW 73 Posting Whiz

Using 10 as your max, you can multiple by 0.1. For example a trackbar value of 5 * 0.1 would give you a percentage of 0.5

TomW 73 Posting Whiz

If 10 is your max value, then you have to figure out what calculation would equate 10 being 100%, 5 being 50% etc.

For instance
TrackBar1.Maximum = 100
TrackBar1.Minimum = 0
TrackBar1.Value = 50

Form_Load
Me.Opacity = TrackBar1.Value / 100 'Result Opacity = 0.5

TomW 73 Posting Whiz

Although you can upgrade some projects it doesnt really convert them to .Net. You are better off starting a new .Net project and just using the old project as a guideline for what needs to be recreated.

TomW 73 Posting Whiz
TomW 73 Posting Whiz

Remember that Opacity is a percentage; so a trackbar value of 50 isnt going to help in the form.opacity value. You need to convert it to 0.50.

Me.Opacity = Dialog2.TrackBar1.Value / 100
TomW 73 Posting Whiz

Hi Tripes, that is fine and not a contradicition. The problem of course is that the wizard generated path is different on your computer then after you deploy. You can still set the database path to something different at run time. Once you create your valid database path at runtime, have it overwrite the existing saved setting.

TomW 73 Posting Whiz

Glad it works for ya. Dont forget to update the thread as solved. :)

TomW 73 Posting Whiz

Seems your are already done with your project. Sorry for the late response, Ive been unable to get back in a timely manner.

Just for your understanding I wanted to point out a few mistakess. First you dont need a double (pun) conversion; you dont need to convert first to a double and then to a decimal. Converting straight to the datatype you want is fine. Second with the Decimal.TryParse method you dont need to convert (cdec()) to a decimal, it will automatically do that for you.

The TryParse has two purposes, first it will automatically convert your value into the variable you provide and second it will return a true/false answer whether it was successfull or not. Lastly you wouldnt want to use Decimal.TryParse to store a value into a datatype of double, in that case either change the variable datatype to a decimal or use a Double.TryParse.

Dim dblHoursUsed As Double     ' to hold hours used
        Dim decAmountDue As Decimal
        decAmountDue = CDec(CDbl(txtHoursUsed.Text))

        ' Check the number of hours used and exit if it contains
        ' invalid data.
      If Decimal.TryParse(txtHoursUsed.Text, CDec(dblHoursUsed)) Then
            lblNumberofHours.Text = "Success!"

        End If
TomW 73 Posting Whiz

Im not sure I understand what your asking or even what your trying to do here. Can you please clarify with more detail.

TomW 73 Posting Whiz

That would be caused by a value within the textbox unable to be converted. I have two suggestions for this, the first which is the better solution may not be allowed by your class assignment and that is to use a NumericUpDown control instead of a textbox. It works the same as a textbox but only allows users to enter numbers and it returns a decimal value. My second suggestion for this would be to use Decimal.TryParse or Double.TryParse, both have examples in the help file, if you still need help with that let me know. (I would suggest using decimal over double for currency values)

Im at work now myself so it is hard for me to go line by line & figure out what your coding is doing.

TomW 73 Posting Whiz
If radPackageA.Checked = True Then
        dblAmountDue = 9.95

        If (dblHoursUsed > 10) Then
                dblAmountDue = 9.95 + (dblHoursUsed - 10) * 2.0
        End If
        lblTotalAmountDue.Text = CStr(dblAmountDue)

ElseIf radPackageB.Checked = True Then
        dblAmountDue = 14.95
ElseIf (dblHoursUsed > 20) Then
        dblAmountDue = 14.95 + (dblHoursUsed - 20) * 1.0

        If radPackageC.Checked = True Then
                dblAmountDue = 19.95
        Else(nonprofit) Then
                dblAmountDue = dblAmountDue * decDiscountRate
        End If

        ' Display the amount due.
        lblTotalAmountDue.Text = CStr(dblAmountDue)
End If

The only spot your adding any info back to a label is in the first part of that If statement where radPackageA.Checked = True or if A & B are both not check and Hours are greate then 20

TomW 73 Posting Whiz

You can set the following property to have it select a whole row:
DataGridView1.SelectionMode = FullRowSelect

You can also hide any of the columns of data that you want in your coding:
DataGridView1.Columns(index or columnname).Visible = False

TomW 73 Posting Whiz

So whats your question/problem?

TomW 73 Posting Whiz

I downloaded that example, it is actually in vb.net not C#

TomW 73 Posting Whiz

I belive that is the files for Sql Server Reporting Services. I believe there supposed to be web browser based type reports but am not positive.

TomW 73 Posting Whiz

I'm not sure what your referring too, if not CR what type of report file are your referring too? PrintPreviewDialog maybe?

TomW 73 Posting Whiz

Like you, I would think there would be an easier way of dynamically loading an image to a report for each record. Googling the subject, so far I'm only finding references similar to first converting the image into a byte array and passing that. I'll keep looking for a LoadImage type method but in the mean time, if you decide to use an example similar to the above C# link, I can covert it to a VB.Net example for you.

If so I have a couple of questions; such as how your calling the report in the first place and how many records show per each report (is it only one member per report or all 400 members each with there own images)?

Just a theory; I'm also wondering if perhaps there is a way to pass the image path as a paramter for the report and have that load an image box. But again I guess that would depend if your report is showing one person at a time or not.

Personal choice; I dont like CR's loading my report data. For instance I dont like pre-assigning it to a datasource (I have multiple sources) and giving the report the control to load the data directly from the db. Its to complicated and in most cases runs slower then needed; however speed of loading a report may or may not be an issue for you. My personal preference is to create a blank report attaching only …

TomW 73 Posting Whiz

As I said previously you can use a DataGridView control, you can fill a dataset and attach the table to the DGV.DataSource and it will create all 3 columns including column headers. A ListView is more manual where you will have to create the headers and insert each of the nodes and sub-nodes per each record.

TomW 73 Posting Whiz

Do you mean you are storing the file path to an image on the local drive?