Begginnerdev 256 Junior Poster

Can you have something like this:

Do While True
    strVarName = ds.Tables("MyTable")(iRow)("varname")
    strVarValue = ds.Tables("MyTable")(iRow)("varvalue")
    If Execute(strVarName, strVarValue) Then Exit Do
    'If the function returns True, the loop will exit.
Loop

Private Function Execute(ByVal sVarName As String, ByVal sVarValue As String) As Boolean
    'Your code here
End Function

Or am I grossly misunderstanding the question?

Begginnerdev 256 Junior Poster

I have written a datadriven application that works with Report Viewer reports.

You will need to look at embedding the reports in the project and calling them when needed.

Begginnerdev 256 Junior Poster

After a quick google search, I have found an article that may be of use to you.

Begginnerdev 256 Junior Poster

You can use Microsoft's Alternative to Crystal Reports.

You can also try this, although it is one I have not tried personally.

Begginnerdev 256 Junior Poster

All that the Visual Studio Shell allows is Crystal Reports to be installed for a runtime. (for reports to run)
This still does not solve your problem with VS2010 Express.

The above solution will only allow you to run reports, not create them. If you wish to create them you might try Microsoft's Alternative to reporting.

Begginnerdev 256 Junior Poster

I think your problem may be just as George and tins have stated.

I think you are simply passing in a string that may have an extra space or a character that's not expected.

Step through and look at the autos to see what is happening with your code.

Begginnerdev 256 Junior Poster

If you are wanting the button - you can try to reference the last clicked button to figure out which one was clicked.

Example:

Dim btnLastClicked As New Button

Private Sub Button2_Click(sender As Object,e As EventArgs) Handles Button1.Click
    btnLastClicked=CType(sender,Button)
    'btnLastClicked will now reference Button1
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    btnLastClicked = Ctype(sender,Button)
    'btnLastClicked will now reference Button2
End Sub

Just food for thought.

Begginnerdev 256 Junior Poster

Under your project's settings you can set the targeted deployment platform.

Project > YourProjectNameHere Properties > Compile > Change Configuration to Release > Change Platform Et Voila

Begginnerdev 256 Junior Poster

As Jim has stated, listviews are zero based.

Therefore:

List.Items(currentTimer - 1).SubItems(List.Items(currentTimer - 1).SubItems.Count).Text = ""

Should be:

List.Items(currentTimer - 1).SubItems(List.Items(currentTimer - 1).SubItems.Count - 1).Text = ""
Begginnerdev 256 Junior Poster

Is the DGV databound?

When you say it would be activating a checkbox and pressing a button, do you mean:

1) The user presses a check box
2) The user presses delete

or

1)The application fires off a checkbox
2)The application fires off a button_click event

Begginnerdev 256 Junior Poster

You can simplify this code with something like this:

Public Class Main
    Dim rnd As New Random
    Dim iNumberToGuess As Integer

    Private Sub btnEnter_Click(sender As Object, e As EventArgs) Handles btnEnter.Click
        Try
            If IsNumeric(txtAttempt.Text) Then
                If CheckGuess(CInt(txtAttempt.Text)) Then
                    Dim res As DialogResult = MsgBox("Do you want to exit the application?", MsgBoxStyle.YesNo, "Congratulations!")
                    If res = MsgBoxResult.Yes Then
                        'Place your code here.
                    ElseIf res = MsgBoxResult.No Then
                        iNumberToGuess = GetRandom()
                        ClearAll()
                    Else
                        MsgBox("Could not determine result!")
                    End If
                Else
                    txtAttempt.Text = Missed(CInt(txtAttempt.Text))
                End If
            Else
                MsgBox("Only numbers can be entered to guess.")
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Function CheckGuess(ByVal iGuess As Integer) As Boolean
        If iGuess = iNumberToGuess Then Return True Else Return False
    End Function

    Private Function GetRandom() As Integer
        Return rnd.Next(0, 30)
    End Function

    Private Function Missed(ByVal iInVal As Integer) As String
        If iInVal > iNumberToGuess Then
            Return "You are to high!"
        Else
            Return "You are to low!"
        End If
    End Function

    Private Sub ClearAll()
        'Place clear code here.
    End Sub
End Class
Begginnerdev 256 Junior Poster

What event are you firing the code at?

Begginnerdev 256 Junior Poster

Which file?

The download, or a file already installed on the computer?

Begginnerdev 256 Junior Poster

Can you please post the block of code that is throwing the error?

Seeing the code would help bring a better understanding of your problem.

Begginnerdev 256 Junior Poster

Try setting the window parent of form2.

'Place a statement to check and launch.
'The check is to safeguard from InvalidOperation Exceptions.

If Form2.Visible = False Then Form2.Show(Me)

'A simple call like:
Form2.TextBox1.Focus()
'Will then focus the control desired.
Begginnerdev 256 Junior Poster

You can try to install the shell.

Integrated

Isolated

Begginnerdev 256 Junior Poster

ListViewItems are zero based.

Therefore 0 will be column one, and 1 will be column two.

Begginnerdev 256 Junior Poster

You will have to look into using Hooks.

Begginnerdev 256 Junior Poster

You will have to keep track of total time elapsed that the application has ran.

You can't assume the app will stay loaded into memory for 10 days - therefore you will have to look into storing the total time it has spent running.

You can use Registry Keys, Serialized files, text files (Easy to "hack") to store the time.

You pull the time into the application on load and start the timer, save the total + instance time on exit.

You check the time on load to see if time = 10days and if so delete the file...

OR

Keep the date/time stored that the application launched the First launch and check to see if the current date is 10 days...

Begginnerdev 256 Junior Poster

Are you wanting to listen for events while the application has focus, or when the application is running and focus isn't required?

If the first, then you just need to implement a timer/event lister on your form and place something like this in the timer.Tick event:

 Private iSecondsElasped As Integer = 0
 Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles tmrInactive.Tick
    Try
        If iSecondsElasped = 300000 Then '5 minutes
            Application.SetSuspendState(PowerState.Suspend, True, False)
        Else
            iSecondsElasped += 1
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

If the application does not have focus, and you are wanting to listen for any actions (Mouse movement/keyboard input) - you will have to use hooks.

Begginnerdev 256 Junior Poster

If you want to search for all occurrances simultaneously, then you might want to check into multithreading.

Begginnerdev 256 Junior Poster

No problem friend! Glad you could find a resolution!

Begginnerdev 256 Junior Poster

If you are using datasets - You may have the problem of opening and closing a connection the same table multiple times.

When I do this I declare one connection that will stay open until all operations are completed on that table - then close.

If this is not the case - one thing that you can do is to create a test in the dll solution to check the code in debug to see if it is doing something undesirable.

Begginnerdev 256 Junior Poster

It appears that in the coversion from VB.NET to C# that the code is not a working C# code.

Try something like this:

private WebResponse CreateDirectory(string sDir)
{
    try {
        FtpWebRequest req = FtpWebRequest.Create(sDir);
        req.Credentials = new NetworkCredential("username", "passw");
        req.Method = WebRequestMethods.Ftp.MakeDirectory;
        WebResponse Response = req.GetResponse;
        return Response;
    } catch (Exception ex) {
        MessageBox.Show(ex.ToString());
        return null;
    }
}

When you say "This does not work either" do you mean that the code doesn't compile or that the code does not behave as wanted?

Begginnerdev 256 Junior Poster

It is not possible (that I know of) to physically turn off a monitor (simulate the power button being pressed) via code. Again, I would check with your monitor manufacturer to see if they are a rare exception to this.

To do as you wish, you would have to kill power to the monitor. The monitor being a peripheral device - this would not be possible unless you speak with the hardware in the device. I do not know of any manufacturers that support 100% power termination via software.

Begginnerdev 256 Junior Poster

Here is some documentation on Method overloading.

Begginnerdev 256 Junior Poster

You would call the code under your button click and pass in the path to create.

Begginnerdev 256 Junior Poster

Kind of an OCD thing - but You can make your code a little cleaner with something like this:

Dim iCount as Integer = 1
For Each t As TextBox In Me.Controls
    xlSheet.Cells(1,i).Text = t.Text
    i+=1
Next
Begginnerdev 256 Junior Poster

Have you verified that the ftp site allows folder creation?

Also, you can clean the code with something like the following:

private WebResponse CreateDirectory(string sDir)
{
    try {
        FtpWebRequest req = FtpWebRequest.Create(sDir);
        req.Credentials = new NetworkCredential("username", "passw");
        req.Method = WebRequestMethods.Ftp.MakeDirectory;
        WebResponse Response = req.GetResponse;
        return Response;
    } catch (Exception ex) {
        Interaction.MsgBox(ex.ToString());
        return null;
    }
}
Begginnerdev 256 Junior Poster

If the library's source code is not accessible - then you can't.

Only if the function takes a structure in as a parameter can you pass it in.

You would have to recreate the function. ( to overload the first )

If you DO have the source code, just modify the dll et voila.

Begginnerdev 256 Junior Poster

Most definitely.

See this.

Begginnerdev 256 Junior Poster

You might also want to look into using a data adapter do reduce the amound of code you have.

For example:

Private Sub UpdateData()
    'You can place your select statment here...
    'Don't worry about selecting certian columns... you will only edit the ones you want in the code below.

    Dim da As New OleDB.OleDBDataAdapter(New OleDB.OleDBCommand("SELECT * FROM MyTable WHERE Column=Value",myConnection))
    Dim ds As New DataSet

    Try
        'If your connection is not open, do so before calling this.
        da.Fill(ds,"MyTable")

        If IsNothing(ds.Tables("MyTable")) = False Then
            'If you create a new row - you call insert, if you modfiy an existing row - call update.
            Dim dr As DataRow = ds.Tables("MyTable").Rows.Add

            With dr
                'Place your statements here.
                'Example:
                dr("Column1") = TextBox1.Text
            End With

            'If Update
            da.UpdateCommand = New OleDb.OleDbCommandBuilder(da).GetUpdateCommand
            'If Insert
            da.InsertCommand = New OleDb.OleDbCommandBuilder(da).GetInsertCommand
            'NOTE - A PRIMARY KEY MUST BE PRESENT IN THE TABLE.

            da.Update(ds.Tables("MyTable"))               
        Else
            MsgBox("Could not retreive table data!" & vbcrlf & "Process aborted!")
            Exit Sub
        End If

    Catch ex As Exception
        MsgBox(ex.ToString())
    Finally
        'Can close here if needed/wanted
        myConnection.Close()
        da.Dispose()
        ds.Dispose()
    End Try
End Sub
TnTinMN commented: nice example +6
Begginnerdev 256 Junior Poster

What you are doing is trying to manipulate hardware with software. You will have to contact the manufacturer of the LCD to see if the LCD allows that functionaly. Closest thing I know of would be to kill power to the GPU. (dangerous, would not reccommend doing this)

I think you are wanting a sleep, right?

Something like this would do that:

Application.SetSuspendState(PowerState.Suspend, True, False)
Begginnerdev 256 Junior Poster

No problem friend. =)

Begginnerdev 256 Junior Poster

My appologies. I had typed that code into the editor without a copy of VS handy.

Replace:

ds("MyTable").Rows(0)("ColumnName")

with

ds.Tables("MyTable").Rows(0)("ColumnName")
Begginnerdev 256 Junior Poster

You can fix your problem by simply opening the connection to communitcate.

Use Reverend Jim's Code and add the following line before da.Fill(ds)

da.SelectCommand.Connection.Open()
da.Fill(ds)
Begginnerdev 256 Junior Poster

Here is an example in C# (Translate) to use as a reference point.

Begginnerdev 256 Junior Poster

Well you need to do the following:

1) Sit down and figure out what data needs to be stored ( You WILL need a database )
2) Choose the database that's right for you.
3) Design your atomic tables (1NF,2NF,3NF)
4) Desing your GUI (With the end user in mind)
5) Develop a flowchart for your application
6) Write the code.

And if by Tally you mean the accounting software - you will want to ask integration questions on their development forum.

Begginnerdev 256 Junior Poster

Does rumType.ToString() return a value?

Step through the code in debug, and use intellisence to check if it does.

Begginnerdev 256 Junior Poster

I use the following methods when I am editing data:

Dim Con as New OleDBConnection("MyStringHere")
Dim da As New OleDBDataAdapter("SELECT * FROM table",Con)
Dim ds As New DataSet

Try
   Con.Open()
   da.Fill(ds,"MyTable")

   ds("MyTable").Rows(0)("ColumName") =  Me.Jan_Revenue2.Text 
   ds("MyTable").Rows(1)("ColumName") =  Me.Feb_Revenue2.Text 
   ds("MyTable").Rows(2)("ColumName") =  Me.Mar_Revenue2.Text 

   da.UpdateCommand = New Data.OleDb.OleDbCommandBuilder(da).GetUpdateCommand
   da.Update(ds.Tables("MyTable"))
Catch ex As Exception
    MsgBox(ex.ToString)
Finally
    Con.Close()
End Try
Begginnerdev 256 Junior Poster

You can find a code translator for C#/VB.NET that will translate the code into something you can understand. (Hopefully)

Begginnerdev 256 Junior Poster

After seeing quite a few posts today asking about event handlers for dynamicly created controls, I have decided to give a little example for reference.

Note that you should check Microsoft's Documentation ( or research from web ) of any control if you are struggling

Begginnerdev 256 Junior Poster

You can try something like this:

Dim WithEvents MonthCalendar1 As New MonthCalendar

Private Sub MC1_DateChanged(sender As Object, e As DateRangeEventArgs) Handles MonthCalendar1.DateSelected
    'This will get the dates
    Dim dtStart As Date = e.Start
    Dim dtEnd As Date = e.End

    'This will create a timespan from those dates.
    Dim dtRange As TimeSpan = dtEnd - dtStart
End Sub
Begginnerdev 256 Junior Poster

Try building a custom handler for it.

'Declare the textbox as so:
Dim WithEvents txtBox1 As New TextBox

Private Sub txtBox1_MouseDown(sender As Object, e As Windows.Forms.MouseEventArgs) Handles txtBox1.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Left Then
        MsgBox("Left mouse button was pressed!")
    ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
        MsgBox("Right Mouse Button was pressed!")
    ElseIf e.Button = Windows.Forms.MouseButtons.Middle Then
        MsgBox("Middle mouse button pressed.")
    Else
        MsgBox("The button pressed was: " & e.Button.ToString)
    End If
End Sub

Or you can add the handlers manually:

AddHandler txtBox1.MouseDown, AddressOf txtBox1_MouseDown

Private Sub txtBox1_MouseDown(sender As Object, e As Windows.Forms.MouseEventArgs)
    If e.Button = Windows.Forms.MouseButtons.Left Then
        MsgBox("Left mouse button was pressed!")
    ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
        MsgBox("Right Mouse Button was pressed!")
    ElseIf e.Button = Windows.Forms.MouseButtons.Middle Then
        MsgBox("Middle mouse button pressed.")
    Else
        MsgBox("The button pressed was: " & e.Button.ToString)
    End If
End Sub
Begginnerdev 256 Junior Poster

I am not fully understanding your question.

If you are asking for the code you are so close.
Something like this:

  If ComboBox1.Text.Contains("x") Then
            Dialog1.ShowDialog()
  End If

If not, then what ARE you asking?

Please explain in more detail.

Begginnerdev 256 Junior Poster

The easier solution would be to set the control's anchors in the desinger.

This will cut down on code.

Unles, of course, you are creating these controls on runtime.

Begginnerdev 256 Junior Poster

Sounds more like a torjan/virus than a browser hijack.

Try Malwarebytes - It's free and works great.

Begginnerdev 256 Junior Poster

I am assuming you are using a project data source?

Is this correct?

If so, what error/message are you getting when you change the connection string?

If not, where is the ConnectionString type coming from?

Is it a custom class/type/structure?

Begginnerdev 256 Junior Poster

I prefer to keep the forum G rated.

You will have to use your imagination. :)

For S***'s and giggles.

Begginnerdev 256 Junior Poster

Is this ConnectionString a Type, or are you refering the the SQLClient.ConnectionString property?