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

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

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

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

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 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

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

I prefer to keep the forum G rated.

You will have to use your imagination. :)

For S***'s and giggles.

Begginnerdev 256 Junior Poster

Have you tried setting the form properties in designer mode instead?

Just for S's & G's?

Begginnerdev 256 Junior Poster

No problem!

Please don't forget to close the thread by pressing the ("Mark This Thread as Solved") button at the bottom of the page!

Begginnerdev 256 Junior Poster

Something like this:

    Dim ts As TimeSpan = dtpTimeOut.Value - dtpTimeIn.Value
    txtDailyHrs.Text = ts.Hours & ":" & ts.Minutes

Will display like this:

Date1: 08:00AM 1/24/13
Date2: 05:15PM 1/24/13

Text: 9:15

Begginnerdev 256 Junior Poster

I must be a wizard!

I set the form border style to none and then set the form to maximize on form load.

Works like a charm for me.

Do you have any special form drawing code?

Begginnerdev 256 Junior Poster

The first column in a listview hold's the value placed in the LVI's .Text property.

Example:

|Record|  Name |  Age  |  Date |
|.Text |SubItem|SubItem|SubItem|

This being said - you need to change your code to reflect this:

lvwItem = ListView 1. Items. Add (reader.G etString (0))

To:

lvwItem.Text = reader.GetString(0)
lvwItem.SubItems.Add(reader.GetString(1))
lvwItem.SubItems.Add(reader.GetString(2))
Begginnerdev 256 Junior Poster

Try this to see if the byte value is generating an image correctly:

Using msStream As New IO.MemoryStream(pictureData)
    picture = Image.FromStream(msStream)
    If IsNothing(picture) = False Then
        frm.PB1.Image = picture
    Else
        MsgBox("Picture returned nothing")
    End If
End Using
Begginnerdev 256 Junior Poster

There will be a button at the bottom of this page that reads:

"Mark this thread as solved"

Begginnerdev 256 Junior Poster

No problem friend!

Please do not forget to mark the thread as solved. =)

Begginnerdev 256 Junior Poster

Try a parameterised query:

  "INSERT INTO @Table (col1,col2,col3) VALUES (@val1,@val2,@Val3)"
Begginnerdev 256 Junior Poster

Try something like this:

Public Class Main
    Dim popup As New Windows.Forms.ToolStripDropDown()
    Dim host As Windows.Forms.ToolStripControlHost

    Private Sub Open_Click(sender As System.Object, e As System.EventArgs) Handles btnOpen.Click
        Try
            With popup
                .Margin = Windows.Forms.Padding.Empty
                .Padding = Windows.Forms.Padding.Empty
                .Size = New Size(150, 150)
            End With

            host = New Windows.Forms.ToolStripControlHost(Panel1)

            With host
                .Margin = Windows.Forms.Padding.Empty
                .Padding = Windows.Forms.Padding.Empty
            End With

            popup.Items.Add(host)
            popup.Show()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub Close_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
        Try
            popup.Items.Clear()
            popup.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class
Begginnerdev 256 Junior Poster

Declare the popup in a class wide variable to be able to manipulate it class wide.

Begginnerdev 256 Junior Poster

Query side, you can try this:
Replace Type with the column that holds your values.

SELECT * From Table ORDER BY Type ASC

For list based, try this:

Dim lstString As New List(of String)

'Add the items to your list

lstString.Sort()

'The default sort function sorts Ascending - for sorting of another type - write your sort function and pass it into the sort's parameters.

Then to load them into the textbox, you can do this:

For i = 0 to lstString.Count - 1
    If i < lstString.Count - 1 Then
        TextBox1.Text &= lstString(i) & ", "
    Else
        TextBox1.Text &= lstString(i)
    End If
Next
Begginnerdev 256 Junior Poster

You have three options:

You can call the .Close() Sub procedure:

popup.Close()

This will close it, but the object remains in memory.

You can call the .Dispose() Sub procedure:

popup.Dispose()

This will release all resources for it, but waits for the garbage collector to grab it.

You can also set it to nothing - This will nullify the object:

popup = Nothing
Begginnerdev 256 Junior Poster

Do you have crystal reports installed on the developer machine?

If not - see here.

If so - Here is a great reference project on CodeProject.

Begginnerdev 256 Junior Poster

I appologize. I was writing the code quickly - and forgot the New therefore the interpreter looks at the () as an array identifier.

Replace:

Dim curItem as ToolStripControlHost()

With

Dim curItem as New ToolStripControlHost(Panel1)
Begginnerdev 256 Junior Poster

You are creating a new one every time - but are you deleting the old one?

If Not, you need to keep a reference of it. Maybe a class wide variable called "curItem" and dispose of it before creating the new one?

'Example:

Dim curItem as ToolStripControlHost()

'In Button_Click
 If IsNothing(curItem) = False Then curItem = Nothing

 'Your Code here

 host.Padding = Padding.Empty
 'host.Width = 50
 curItem = host
 popup.Items.Add(host)
Begginnerdev 256 Junior Poster

Let me try to clarify this a little:

You are:
1) Creating a toolstripdropdown
2) Adding a panel to the dropdown
3) Repeating this process for every time a button is clicked?

Is this true?

Begginnerdev 256 Junior Poster

No, the .Net framework/Oracle takes care of the rest for you. (Provided you coded the application correctly)

Begginnerdev 256 Junior Poster

You can use this for Microsofts instructions on setting the folder cache.

The example is for Windows Server 2008, which I'm sure you can do the same for Windows 7.

Begginnerdev 256 Junior Poster

You will have to re-write the file.

Example:

Dim SR as New StreamReader(path)
Dim SW as New StreamWriter(path & "tmp")

Do While SR.Peek <> -1
    Dim sCur As String = SR.ReadLine
    If sCur <> Block Then
        SW.WriteLine(sCur)
    End If
Loop

SR.Close
SW.Close

'Next Copy Over the original hosts file 
File.Copy(path & "tmp", path,True)
Begginnerdev 256 Junior Poster

Here is a small project on CodeProject that you can use as a reference point.

Ancient Dragon commented: Excellent :) +14
Begginnerdev 256 Junior Poster

Here is a link to code that will allow you to read on an element basis.

Begginnerdev 256 Junior Poster

For the server you can do the following:

Get Client Name
Check if new client:

Dim pathscheme As String = PathOnServer & SomeUniqueClientValue 'Like a GUID
If IO.Directory.Exists(pathscheme) = False Then
    IO.Directory.Create(pathscheme)
End IF

On client Side, you do the same:

If IO.Directory.Exists(pathtoserver) = False Then
    MsgBox("No Directory Found @" & vbcrlf & pathtoserver)
    'Disable controls here
End If

As for the bulk of the code, you are going to have to write some before we can help you out.

Begginnerdev 256 Junior Poster

For the select, you can place the following code in your procedure:

    Try
        Dim da As New OleDb.OleDbDataAdapter(New OleDb.OleDbCommand("SELECT * FROM usertbl WHERE type='" & cboType.Text & "'", dataconn))
        Dim ds As New DataSet

        da.Fill(ds, "Type")

        If IsNothing(ds.Tables("Type")) = False And ds.Tables("Type").Rows.Count > 0 Then
            cboName.Items.Clear()
            For i = 0 To ds.Tables("Type").Rows.Count - 1
                cboName.Items.Add(ds.Tables("Type").Rows(i)("Username"))
            Next
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
Begginnerdev 256 Junior Poster

Can you do us a HUGE favor and indent your code for easier reading?

You can do this by pressing Tab to indent the code. You will see the text turn green when it is done correctly.

Begginnerdev 256 Junior Poster

The code from the post above will test the value in the textbox before entering it into the listbox.

This should accomplish what you are wanting, as for the guessing part, you will have to drop your code in.

I hope this helps. :)

Begginnerdev 256 Junior Poster

Ah, you are storing the values IN the listbox. So the code I posted will be checked every button click, therefore, it will throw a message box(testing values that are already in the listbox)

Is it possible to use a textbox to type, and a listbox to store?

GuessBox

If this is possible, you can just check to see if the item is in the listbox:

 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    If IsDuplicate(TextBox1.Text) = False Then
        ListBox1.Items.Add(TextBox1.Text)
    Else
        MsgBox("You have already guessed this letter.")
    End If
End Sub

Private Function IsDuplicate(ByVal StringIn As String) As Boolean
    'Cycle and Check
    For i = 0 To ListBox1.Items.Count - 1
        If ListBox1.Items(i).ToString.ToLower = StringIn.ToLower Then
            Return True
        End If
    Next

    'Return false (None were found)
    Return False
End Function
Begginnerdev 256 Junior Poster

My question would then be, how are they entering/chosing from a listbox.

Are you allowing only 1 char, or an entire string?

And why a listbox and not a textbox?

Begginnerdev 256 Junior Poster

You could try to add it to an array then search the array for it:

Dim lstString As New List(Of String)


'Assuming they have to press a button to submit their letter
Private Sub Button_Click(sender as object, e as eventargs)Handles Button1.Click

   If lstString.BinarySearch(ListBox1.Text.ToLower) <> -1 Then
       MsgBox("You can only enter a letter once!")
   Else
       lstString.Add(ListBox1.Text.ToLower)
   End If
End Sub

You could do that, or create flow layout panel containing the buttons for A-Z and disable the button on click.

Begginnerdev 256 Junior Poster

If you are popoulating the listbox with a dataset, you just need to refresh the data.

What connection type are you using?

Begginnerdev 256 Junior Poster

If you are using a dataset to fill your listview, and the records are added by dataset row, you can do this.

 MyDataSet.Tables("myTable").Rows(indexFromListView).Delete()
 MyDataAdapter.Update(MyDataSet.Tables("myTable"))
Begginnerdev 256 Junior Poster

Also, you want to use the DTP's .Value attribute, not .Text

Begginnerdev 256 Junior Poster

You are referencing the index of the listview only.

This will ONLY work on the very first delete (Assuming you have an identity column that matches the exact indexes of the listview(Extremely unlikely))

You will need to reference a unique value from the list view item, otherwise, you can only remove it form the listview - not the database.

For example:

(HideThisColumn|Col1|Col2|Col3)
(             3|Name|Date|Info)
(             5|Name|Date|Info)
(             6|Name|Date|Info)
(             9|Name|Date|Info)

If you stored the database indentity column in the first column of the list view, but hid the column, the user will only see col1, col2 and col3.
So when the user clicks the column " 5|Name|Date|Info " You know that that corresponds to the database entry with an identity of 5.

By using the index of the item ( What you are doing now ) you will try to execute a delete statement on the index of 1 (2nd item in the list) which will produce undesired outcomes.

Begginnerdev 256 Junior Poster

What I like to do when using listviews, is to load the table's identity column into the first column of the listview. (Then make the column width 0 to hide it from the user)

Then to reference it, I use:

Dim myUnique As String 'Your data type here

If IsNothing(ListView1.SelectedItems) = False Then
    For Each Itm as ListViewItem in ListView1.SelectedItems
        myUnique = Itm.Text
    Next
Else
    MsgBox("Please select an item first!")
End If

You have just referenced the identity that is stored in the first (hidden or not) column of the row.

You can now use this to manipulate data/the list view.

Begginnerdev 256 Junior Poster

Try This:

    Dim MyTable As String
    MyTable = "Table1"

    For i = 0 To ds.Tables(MyTable).Rows.Count - 1
        'Do Work
    Next
Begginnerdev 256 Junior Poster

Try

If TextBox1.Text = "A" Or TextBox1.Text = "B" Or TextBox1.Text = "C" Then
    'Do Work
End If
Begginnerdev 256 Junior Poster

What problems are you getting with this code?

Begginnerdev 256 Junior Poster

If you are making an app for "live" data manipulation you need to research what methods you want to use:

DataGrid
ListViews
Reports
Ect...

You will need to design your tables on an atomic level(3NF) and design your GUI for the end user (not your own preference).

You will need to look at deployment methods as well.

Some of these include:

ClickOnce
InstallShield
InnoSetup

Hope this gets you started!