Begginnerdev 256 Junior Poster

You can simplify the process by:

Convert the text to all lower case:

Dim sConversionString as String = TextBox1.Text.ToLower()

Then do something like the following:

If sConversionString.Contains("n229") Or sConversionString.Contains("n 229") Then
    'Do Work
End If
Begginnerdev 256 Junior Poster

Which connection are you using to connect to your database to retrieve the data?

ADO
OleDB...ect

Begginnerdev 256 Junior Poster

Why are you using a DataTable and not an adapter/dataset?

Do you have a requirement to use only a data table?

Begginnerdev 256 Junior Poster

You need to make use of the sender object.

Example:

Private Sub Button_Click(sender as System.Object, e as System.EventArgs)
    Try
        Dim ST As New Button

        ST = TryCast(sender,button)

        ST.BackColor.ToString = TextBox1.Text
    Catch
        MsgBox(ex.message)
    End Try
End Sub

Programaticly add this handler to each button ( To rid yourself of the long line of handles clauses )

Example:

For Each btn as Button in Me.Controls
   AddHandler btn.Click, AddressOf Button_Click
Next

'Assuming those buttons are the only ones that exist.

Hope this helps.

Begginnerdev 256 Junior Poster

Try this instead:

For remove use the following:

listview6.Items.Remove(listview6.SelectedItems.Item(0))

'If multiple items are selcted use

For each itm as ListViewItem in ListView6.SelectedItems
    listview6.Items.Remove(itm)
Next
Begginnerdev 256 Junior Poster

G Waddell's suggestion is the quickest way to do what you are wanting.

Begginnerdev 256 Junior Poster

Sorry for my leave of absence.
I have found the solution; the controls were being disposed then recreated in code. (No clue why he did this.)
Changed the disposing to clearing all controls and it works fine!
Thank you for your help!

Begginnerdev 256 Junior Poster

Thank you for the link.

I have tried this and it is still returning a null reference.

The page validates before getting searched, could this cause a null reference?

(Some what new to ASP)

Begginnerdev 256 Junior Poster

They are, I had forgotten to add them. (Don't want to copy/paste 400 lines of asp markup)

Sorry!

Begginnerdev 256 Junior Poster

I have tried stepping all the way down the page's structure to no avail.

It works some times, then other times it just returns null and throws a null reference exception when I try to perform any actions with/against it.

Begginnerdev 256 Junior Poster

Hello my fellow Daniwebers,

I have a question for you.

I have an asp.net page that contains a structure that looks like so:

<asp:MultiView>
    <asp:View>
        <asp:UpdatePanel>
            <asp:Panel>
                <asp:TextBox ID="txtStartDate" 
                             runat="server"
                             AutoPostBack="true" />
                <asp:TextBox ID="txtEndDate" 
                             runat="server"
                             AutoPostBack="true" />
            </asp:Panel>
        </asp:UpdatePanel>
    </asp:View>
</asp:MultiView>

The curious problem is that I can't reference the two controls.

(The code behind is vb.net)

I have used:

txtStartDate.Text

and

Dim txtStart as TextBox = FindControl("txtStartDate")
Dim txtStart as TextBox = panelName.FindControl("txtStartDate")

To no avail.

Some times they will retrieve the control, but most of the time they will return null values.

Has anyone else had this issue before?

If so, can you please shed some light on my situation?

I would greatly appreciate it!

Thank you,
Begginnerdev

Begginnerdev 256 Junior Poster

It would be wise, if you are after the razzle dazzle, to use WPF instead of Winforms.

WPF allows alot of glitter and sparkles for your gui.

Begginnerdev 256 Junior Poster

Here is an open source HMS. As Jim said, it will most likely not fit your needs.

Click Here

Begginnerdev 256 Junior Poster

If you are not wanting to use the time, you can simply set the dtp's format to ShortDate and it will remove the time.

If you are wanting the time, you will need to do some error checking to make sure the format will match that of the database.

Begginnerdev 256 Junior Poster

Is the cust ID field an auto number field?

Begginnerdev 256 Junior Poster

Do you have a flowcharting program?

If not, try raptor:

Click Here

Begginnerdev 256 Junior Poster

Have you learend to flowchart yet?

If so, just lay the problem out in flowchart form..the answer will then be clear.

It will only be a syntax issue from there.

As for solving homework for you, we can't do that. You may get a good grade now, but you have not learned anything.

"Give a man a fish, he will eat for a day. Teach a man to fish, he will eat for a lifetime."

Begginnerdev 256 Junior Poster

Here is an excellent source for working with the registry. I have used this as a reference in the past, and it will cover everything you will need to know.

As for application settings, open the project designer (My Project) and click the Settings tab.

Create a new variable to store the date in and give it a value.

To access this while coding, do the following.

Dim date1 as Date = My.Settings.MyDate

For updating the date:

My.Settings.MyDate = Now.AddMonths(6)
My.Settings.Save() 'Critical to save or the changes will not be commited.

When using settings, the application settings are stored in an xml file in the application's directory. (Easy to access by user.)

This can be changed and can lead to dishonesty from the user.

Begginnerdev 256 Junior Poster

Think about it this way.

You need a total of 5 lines.
Each line's printed value is n+2 from last value.
Each line's length is decreased by 2 each iteration.

Have you learned to flowchart yet?

Begginnerdev 256 Junior Poster

By using nested for loops.

Something tells me you are asking for homework code...

Do you have any code where you have tried this on your own?

Begginnerdev 256 Junior Poster

Also, another suggestion. Instead of using the value stored in the program ( Value will remain the same after refresh when the application is reloaded. ) think about using registry keys or application settings.

The only issue with these are if the user finds them, they can simply edit them to add more time...

You will have to implement countermeasures for this.

Begginnerdev 256 Junior Poster

Do you have an image of the map you are using for the rails?

As for the colors, you can set the tag to the name of the color you want the box to be.

Begginnerdev 256 Junior Poster

Create an new entry in the database, then store the value into the coulmn specified:

If you are doing all the statements by hand, try something like this:

Try
    Dim con As New System.Data.SqlClient.SqlConnection("connectionStringHere")
    con.Open()
    Dim cmd As New System.Data.SqlClient.SqlCommand("INSERT INTO table1(column1) VALUES ('" & TextBox1.Text & "')", con)
    cmd.ExecuteNonQuery()
Catch ex As Exception
    MsgBox(ex.Message)
End Try
Begginnerdev 256 Junior Poster

You will only call the function when a key needs to be entered.

If you are wanting only one renew ( for a total life of one year )

Then you can think about the situation from the other way.

Set Date1 to 1 year from the first use, and at the 6 month place, ask for another key.

Begginnerdev 256 Junior Poster

I concur with Pgmer.

There are many resouce out there for threading/background workers.

Example:

Click here for threading

or

Click here for background worker

Begginnerdev 256 Junior Poster

You will need to write a function/sub that will refresh the expiration date on key entry.

Something Like:

Private Sub RefreshDates(ByVal sKey As String)
    If isAuthenticated(sKey) Then
        Me.Date1 = Now.AddMonths(6)
    Else
        Return
    End If
End Sub

Private Function isAuthenticated(ByVal key As String) As Boolean
    'validate key and return true here
End Function
Begginnerdev 256 Junior Poster

If this is tied to a database, which it is, you will have to create a new column in the database every time you insert a value.

This is not a good thing, considered you could possibly have an infinitely increasing table.

Is it possible you can store the values in rows instead of columns?

Begginnerdev 256 Junior Poster

You are calling this from the CheckChanged event.

That means when it will repeat the code when you use:

Me.RadioButton3.Checked = True

When you are setting the value, the application will raise the CheckChanged event.

This will be an infinite loop, right?

You can try to drop the code in the radio button's Click event.

Hope this helps!

Begginnerdev 256 Junior Poster

I am trying to wrap my head around what you are wanting...

Are you:

A) Wanting to insert the value into the first column ( all rows ) then shift the columns right on the next insert

-or-

B) Wanting to create a new row with the value in the first column

If you are wanting A, you will have to create a new column for every entry.

If you are wanting B, you will have to create a new row for every entry.

Begginnerdev 256 Junior Poster

If you are not commiting the changes to the database on insert, then you will just refresh the data - erasing the values inserted on the next insert.

What database are you using?

What methods are you using to connect to the database?

Begginnerdev 256 Junior Poster

By searching the forumns, I found found another post looking for system memory here

As for video memory, are you using an aftermarket GPU or are you using an onboard or on chip GPU?

Begginnerdev 256 Junior Poster

Can you post a snipped of the code that loads/colors the listview items?

I see that you are coloring after you populate, why not color while you populate?

Begginnerdev 256 Junior Poster

Edit to last post

e.Cancel = True

Will only work with certain event arg types.

Return 'For a sub'
'-or'
Return Nothing 'For a function'
'I recommend returning the value that is checked against.'
'Example:'

If MyFunction(0) = True Then

End If


Private Function MyFunction(ByVal myVal as Integer)
    If MyVal > 1 Then
        Return True
    Else
        Return False
    End If
End Function

Use these in those cases

Begginnerdev 256 Junior Poster

Just place:

If TextBox.Text <> "" or TextBox1.Text <> String.Empty Then
    'Place code here'
Else
    MsgBox("Please enter a valid name.")
    e.Cancel = True
End If

Better question...Does each user have an active directory login and are they using this login to launch the application?

Begginnerdev 256 Junior Poster

The color is not applied to only the viewable area of the data?

Begginnerdev 256 Junior Poster

After doing a little research, I have found some possible fixes:

Set the ListView's HideSelection property to true

Some one has suggested useing Invalidate(), allowing the listview to repaint at the next paint action. (Less taxing)

I will continue looking.

Begginnerdev 256 Junior Poster

If the api you are using targets the WIA api on windows XP systems, it will not work on Vista or any machine afterwards.

From my experiences with WIA, the function calls from WIA 1.6 to 2.0 is a small jump. I have seen that alot of the types are the same, just called differently.

You might want to research targeting different platforms, and compiling your projects with the needed libraries to work on those platforms.

As always, Microsoft's documentation of WIA is poor. ( to say the best ) You will be working with Interopt. I have managed to find a small library that is open source (of all places I found it on youtube! ) that can be used on Vista, 7, 8? machines.

You can find it Click Here

This library uses both TWAIN and WIA and will do what you are looking for. It will take a little "elbow grease" but it will work out in the end.

P.S. Don't get discouraged, it took me about 2-3 months of research to start to understand imaging API's.

Begginnerdev 256 Junior Poster

Is the client computer running .NET Framework 4.0 Client while the dev machine is running Full?

I have had issues with client Vs. full before. I wouldn't rule that out completely.

Begginnerdev 256 Junior Poster

Talk about resurrecting dead threads.

Start a new thread with your problem, some of these users might not even be on Daniweb any more.

Begginnerdev 256 Junior Poster

You can declare a private boolean variable and a public property like so:

Private buttonEnabled As Boolean = True

Public Property EnableButton As Boolean
    Get
        Return Me.buttonEnabled
    End Get
    Set(value As Boolean)
        Me.buttonEnabled = value
    End Set
End Property

Then in the form's load event handler place the following code:

buttonBeingManipulated.Enabled = buttonEnabled

To change the value create a new instance of the value on the form you are sending the command from:

    Dim f99 as New Form99

    f99.EnableButton = False
    'The button will be disabled'
Begginnerdev 256 Junior Poster

Is the data grid view bound to a data base or data set?

Begginnerdev 256 Junior Poster

You have way to many event handlers...

Did you know you can share handlers?

Example:

Private Sub CheckChanged(sender as object, ByVal e As EventArgs) Handles CheckBox1.CheckChanged,CheckBox2.CheckChanged,CheckBox3.CheckChanged
   If Ctype(sender,CheckBox).Checked Then TextBox.Visible=True Else TextBox.Visiable = FALSE
End Sub

As for the mssg, are you pulling the value from the text box that is visible?

Begginnerdev 256 Junior Poster

You can also create one function using Jim's method:

Private Sub FocusChanged(sender As Object, e As EventArgs)

    If CType(sender, TextBox).Focused = True Then
        CType(sender, TextBox).BackColor = Color.FromArgb(65, 65, 65)
    ElseIf CType(sender, TextBox).Focused = False Then
        CType(sender, TextBox).BackColor = Color.FromArgb(60, 60, 60)
    End If

End Sub

And just add the handlers to each textbox:

'Add this code in the form load event'

For Each txt As TextBox In Me.Controls
        AddHandler txt.GotFocus, AddressOf FocusChanged
        AddHandler txt.LostFocus, AddressOf FocusChanged
Next
iFrolox commented: Thank you +2
Begginnerdev 256 Junior Poster

Are you using a DateTimePicker control?

If so, you can make use of the ValueChanged event.

If you listbox has multiple values, reference the value you want to change first.

Example:

Private selectedItem As Object 'Define your data type here'
'Example: selectedItem as Date'

Private Sub ListBox1_Click(sender As System.Object, e As System.EventArgs) Handles ListBox1.Click
    selectedItem = ListBox1.SelectedItem
    'Example with typed data: selectedItem = Cdate(ListBox1.SelectedItem)'
End Sub

Now, just change the value of the selected item when the user changes the value on the date time picker.

Example:

Private Sub DateTimePicker1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles DateTimePicker1.ValueChanged
    selectedItem = DateTimePicker1.Value
    'Remember to handle the data types, if you are using string make sure to use the .ToString function ect...'
End Sub

Hope this helps!

Begginnerdev 256 Junior Poster

Awesome, I have frankensteined a function together that works!

Thank you, lola!

Begginnerdev 256 Junior Poster

Hello my fellow DaniWebbers, I have a question for you.

Problem:

I am troubleshooting an ASP.NET (some one else wrote) page that has an insert form.

The user can insert, using linq, into the database.

I want to check the database for the values before inserting the values. (Safeguarding from duplicates)

Question:

Could anyone please guide me through a way to do this? I have tried reading Microsoft's Documentation on LINQ and I am still lost. (Big shocker)

P.S. I know this is an ASP.NETish question. The problem lies in the code behind, therefore; I posted in VB.NET forum.

Thank you,
Begginnerdev

Begginnerdev 256 Junior Poster

I am sorry my friend, but I believe you have posted on the wrong forum.

This is, in fact, the VB.NET forum.

I will flag for a mod to transfer for you.

Begginnerdev 256 Junior Poster

You can use what hericles has posted and append the following:

   Dim con As New SqlConnection("Connection string here")
    con.Open()

    Dim sqls As String = "SELECT col_name1, col_name2 FROM table_name WHERE some_col = some_value;"

    Dim cmd As New SqlCommand(sqls, con)

    Dim da As New SqlDataAdapter(cmd)

    Dim ds As DataSet

    da.Fill(ds, "Values I Need")

    Dim dt As New DataTable

    dt = ds.Tables("Values I Need")

    If dt.Rows.Count > 0 Then
        For i = 0 To dt.Rows.Count - 1
            TextBox1.Text = dt.Rows(i).Item(0)  'col_name2'
            TextBox1.Text = dt.Rows(i).Item(1)  'col_name2'
        Next
    End If
Begginnerdev 256 Junior Poster

Problem 1:

If you are seperating the values with ','; then you can make use of the string split function (asuming all values will be in the same format.)

Just pass in the string from the listbox and then parse the string into an array using string split.

Example:

 Dim ar() As String = Split(ListBox1.SelectedItem, ",")
'This will return something that looks like this'
'String: Chocolate, 10, 24.55'
' ar(0): Chocolate'
' ar(1): 10'
' ar(2): 24.55'

Problem 2:

You should make use of the sender object that is passed in.

You will have to use CType(sender, Form) to manipulate the form from another.

Example:

   Dim callingForm As Form = CType(sender, Form)
   Dim FormName As String = callingForm.Name

Hope this helps!

Begginnerdev 256 Junior Poster

I see you are assigning the value to Y but you are adding X to the list box.

Dim y As Double = (((t / 0.2) * length) * ((0.2969 * (Math.Sqrt(x / length))) - (0.126 * (x / length)) - (0.3516 * ((x / length) ^ 2)) + (0.2843 * ((x / length) ^ 3)) - (0.1015 * ((x / length) ^ 4))))
ListBox1.Items.Add(x)