Begginnerdev 256 Junior Poster

Do you mean something like this?

    Try
        Dim myDir As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "/tmpOldLoc/"
        Dim toDir As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "/tmpNewLoc/"


        If Directory.Exists(myDir) = True Then
            Dim di As New IO.DirectoryInfo(myDir)
            Dim diar1 As IO.FileInfo() = di.GetFiles()
            Dim dra As IO.FileInfo
            For Each dra In diar1
                File.Copy(dra.FullName, toDir & dra.Name)
            Next
        End If

    Catch ex As Exception

        MsgBox("Something went wrong!" & vbCrLf & ex.Message)

    End Try
Begginnerdev 256 Junior Poster

Almost every obect that has an index is treated as a 0th based array.

Arrays will have a terminator character to the end.

Example

Cat

cat = 3 characters, but is actually 4 after the terminator.

Therefore,

 Dim test() As String = {"c", "a", "t"}

 MsgBox(test.Length) 'Returns 3'

 MsgBox(test(0)) 'Returns c'
 MsgBox(test(1)) 'Returns a'
 MsgBox(test(2)) 'Returns t'
 MsgBox(test(3)) 'Outside of bounds. Terminator character."
Begginnerdev 256 Junior Poster

You will want to make sure to subtract 1 from count.

Liike this:

For i As integer = 0 to Me.DtaGridXML.Rows.Count - 1
Begginnerdev 256 Junior Poster

There is

UPDATE table SET column2 = column2 + 1

Begginnerdev 256 Junior Poster

You will have to loop through the datagrid like a table.

Here is another question from Microsoft's Forumns.

Click Here

Begginnerdev 256 Junior Poster

Here is an article on WPF issues.

Begginnerdev 256 Junior Poster

Are the TracebleSOPAllocationItems being stored directly to the grid, or is the grid bound to a database?

Begginnerdev 256 Junior Poster

I am suspecting that the issue is the AllocatedItem.

Correct me if I am wrong, but there will only be object types in the data source right?

You can place the code in a TryCast() to attempt to cast it to the AllocatedItem object.

Begginnerdev 256 Junior Poster

You could try a different method and define a structure.....

Dim stud(24) As Students
Dim tmpStud As Students


Structure Students
    Dim StudentName As String
    Dim CumulativeScores As Double
End Structure




    For i = 0 To stud.Count - 2
        If stud(i).CumulativeScores > stud(i + 1).CumulativeScores Then
            tmpStud = stud(i + 1)
            stud(i + 1) = stud(i)
            stud(i) = tmpStud
        End If
    Next
Begginnerdev 256 Junior Poster

Declare a boolean variable at the top of the class.

public Paused as Boolean = false
'When you fire your click event do this;
If Paused = false Then
    'Pause code here
    Paused = true
ElseIf Paused = True Then
    'Unpause code here.
    Paused = False
End If
Begginnerdev 256 Junior Poster

The correct sql statement would be:

("SELECT * FROM daftarpelajar WHERE '" & cbChoice.Text & "' Like '%" & txtSearch.Text & "%' ORDER by id_pelajar ", conn)
Begginnerdev 256 Junior Poster

I must be totally lost, but didn't you answer you own question with the code you provided?

Are you trying to link code to an external document?

If so, just make the sub public and import the document on the document you wish to have the Undo.

If not, you have already linked the code in the current document.

Begginnerdev 256 Junior Poster

If you are a student, then you shouldn't just request a project.

You should show a little effor before we can offer to help you.

Now, if you have ideas or code, post them.

We can't do your homework for you.

Begginnerdev 256 Junior Poster

Create an orders table to store the meta data of the order, and then store the order id in the customer table.

Begginnerdev 256 Junior Poster

Np, friend.

Begginnerdev 256 Junior Poster

You can get rid of the has rows, and try:

If myData IsNot Nothing Then
   Do While myData.Read
   'Place your code here.
   'Use GetValue instead of .toString
   Loop
Else
MsgBox("Empty Reader")
End IF
Begginnerdev 256 Junior Poster

I have just one question though.

Is a color dialog out of the picture for your program?

If not, it would make your life SO much easier.


Other than that, what is the height of BMP?

Begginnerdev 256 Junior Poster

You can do this in vb

If IsDBNull(value) then
 'Value is null, place code to handle here.
End if
Reverend Jim commented: OK. Not so messy after all. +9
Begginnerdev 256 Junior Poster

Sorry, I typed it on the fly.

I forgot about the new Point.

Try this instead.

'For new Y position.
Button1.Location = New Point(Button1.Location.X, Me.Width - 30)
'For new X position
Button1.Location = new Point(Me.hieght - 100, Button1.Location.Y)
Begginnerdev 256 Junior Poster

First of all Congratulations.


Second of all, is it possible that this is considered a spammer? Just a question.

M.Waqas Aslam commented: ;) may be yes +5
adam_k commented: yep +9
Begginnerdev 256 Junior Poster

The ancor and dock methods might not always work.

That's when I resort the the following method:

'You will have to play with this to get everything right.
'This will automaticly move when the user resizes the window too.
Button1.Location.Y = Me.Width - 30 
'You can do the same for the X location.
Button1.Location.X = Me.Height - 10
Begginnerdev 256 Junior Poster

Have you tried the .ToString() function?

Example...

TxtRate.Text = dt.Rows(0).Item(1).ToString
Begginnerdev 256 Junior Poster

I am sorry......

I meant.....

TxtRate.Text = dt.Rows(0).Item(1)
Begginnerdev 256 Junior Poster

You will want to create a data table form the database.


Then you will use the selected index of the combobox to pull from the datatable.

Example...

Select Case cbMenu.SelectedItem

Case 1
TxtRate.Text = dt.Rows(0).Column(1)
......


This will get the value stored in the second column of the corrosponding table row.

Assuming the value is in the second column of the same table.

Begginnerdev 256 Junior Poster

Hello everyone!

I am posting this code for anyone who may be having issues with connecting to a database. Feel free to use this code as you wish.


This will be using the OLEDB library.

'Imports
Imports System.Data.OleDb


Public Class Form1

    'Declarations
    Dim con As OleDbConnection
    Dim cmd As OleDbCommand
    Dim sqls As String
    Dim sqlcmd As String




    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'In form_load event, but can be used on button click.

        'For hard coded connection string
        sqls = "Provider=SQLOLEDB;Datasource=YOURSERVERNAMEHERE;" & _
               "Initial Catalog=YOURDATABASENAMEHERE;Integrated Security=SSPI"
        'For dynamic connection string
        sqls = "Provider=SQLOLEDB;Datasource=" & txtServerName.Text & ";Initial Catalog=" & _
               txtDatabaseName.Text & ";Integrated Security=SSPI"

        'Place all connection code in try/catch blocks.
        Try
            'Connect using the string we have just created
            If con.State <> ConnectionState.Open Then
                con.ConnectionString = sqls
                con.Open()
            End If

            'Alternative way is:
            If con.State <> ConnectionState.Open Then
                con = New OleDbConnection(sqls)
                con.Open()
            End If


            'Selecting everything from a database
            sqlcmd = "SELECT * FROM tablename"

            'Selecting a specific value when you have a reference
            sqlcmd = "SELECT * FROM tablename WHERE columnname = referencevalue"

            'Non hardcoded method
            sqlcmd = "SELECT * FROM tablename WHERE columnname = '" & txtDataToSearchBy.Text & "'"

            'Setting the command
            cmd.Connection = con
            cmd.CommandText = sqlcmd

            'Alternative way is:
            cmd = New OleDbCommand(sqlcmd, con)

            'Querying the database
            'Many differny ways.

            'Returns number of rows
            cmd.ExecuteNonQuery()

            'Returns only the first column of first row.
            cmd.ExecuteScalar()

            'Builds a data reader with the current command.
            cmd.ExecuteReader()

            'Good …
Reverend Jim commented: Nice, simple, straightforward example. +8
Begginnerdev 256 Junior Poster

The code above creates a structure, in the form of a class, then passes the string information into the class. It then builds the string and assigns the value to your settings with what ever string name you want it to be.

Then it saves.

To use this, build the class by using the Project > Add Class name it ClassConnectionBuilder. Save the code you have above into that class.

'Creating connection string
Imports System.Data.SqlClient

Public Class ClassConnectionBuilder
    Public Shared Function ConnectionStringBuilder(ByRef Server As String, ByRef database As String, _
                                                   ByRef userid As String, ByRef password As String) As String

        Dim sqlConnString As New System.Data.SqlClient.SqlConnectionStringBuilder() With {
            .DataSource = Server,
            .InitialCatalog = database,
            .UserID = userid,
            .Password = password
        }
        Return sqlConnString.ConnectionString
    End Function
End Class

Then you can use the build by either importing it then using it or providing a full "path".

IE

'Imported
'Importing would be: Imports yourprojectname.ClassConnectionBuilder
SqlConnectionStringBuilder(string,string,string,string)

'Not imported
ClassConnectionBuilder.SqlConnectionStringBuilder

Hope this helps

Begginnerdev 256 Junior Poster
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & spath & ";Persist Security Info=True")

Your connection string might be incorrect, it looks like it is missing some things.

Here is a good reference for connection strings:

http://www.connectionstrings.com/excel

Begginnerdev 256 Junior Poster

If using Visual Studio:

Open visual Studio
Create a new Project -> Windows Forms Application
Give the project a name and create it.

This will show you a blank form labeled form1 with nothing on it.

To add another form go to Project - > Add Windows Form to add the other form

Now, from form1 add a button. You can name it what you want it to be named.

Once you are finished double click the button.

This will bring up the code editor.

From the button click procedure type:

form2.show()

form2 should be replaced with the name that you had given the second form you had added.

This should be an easy way to add and launch another form.