Jx_Man 987 Nearly a Senior Poster Featured Poster

Something like this should working :

Function ReadFileText(ByVal filename As String) As String
        Dim handle As Integer

           ' ensure that the file exists
        If Len(Dir$(filename)) = 0 Then
            Err.Raise 53  ' File not found
        End If

           ' open in binary mode
        handle = FreeFile
        Open filename$ For Binary As #handle
           ' read the string and close the file
        ReadFileText = Space$(LOF(handle))
        Get #handle, , ReadFileText
        Close #handle
End Function

Private Sub Command1_Click()
Dim temp() As String
Dim temp2() As String
Dim FNArr() As String
Dim LNArr() As String
Dim AgeArr() As String
Dim BloddArr() As String

    ' split text file by new line (enter)
    temp = Split(ReadFileText("D:\Dani.txt"), vbNewLine)

    ' get how many rows in array
    x = UBound(temp) 

    ' redim each array with new rows. 
    ReDim FNArr(x)
    ReDim LNArr(x)
    ReDim AgeArr(x)
    ReDim BloddArr(x)

    For i = 0 To x
        ' split each line by semicolon sign
        temp2 = Split(temp(i), ";")

        ' write each data to proper arrays
        FNArr(i) = temp2(0)
        LNArr(i) = temp2(1)
        AgeArr(i) = temp2(2)
        BloddArr(i) = temp2(3)
    Next i

End Sub
Sturdy commented: Thanks for the great code sir. +1
Jx_Man 987 Nearly a Senior Poster Featured Poster
while ((line = sr.ReadLine()) != null)
{
string[] values = line.Split(new string[] {","}, StringSplitOptions.None);
for (int i = 0; i < values.Length; i++)
{
.......
}

i dont know how to add values to the array

I'm little confused here.
Why you need to add value again to the array? You already read text file and store it into array named values.

Jx_Man 987 Nearly a Senior Poster Featured Poster

so, What wrong with your code? any errors?
What you mean about "particular pattern"?
Post your text file sample.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Post your code.
How far you doing this.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Likes minimize all programs :
You can try this :
This use API function. It will same efect when you press "win+D" in keyboard.

Private Const KEYEVENTF_EXTENDEDKEY As Long = &H1
Private Const KEYEVENTF_KEYUP As Long = &H2
Private Const VK_LWIN As Byte = &H5B
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Sub ClearDesktop()
    ' Simulate key press
    Call keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, 0)
    Call keybd_event(Asc("D"), 0, 0, 0)
    ' Simulate key release
    Call keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
    Call keybd_event(Asc("D"), 0, KEYEVENTF_KEYUP, 0)
End Sub


Private Sub Form_Load()
ClearDesktop
End Sub
Estella commented: Great code +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

What you mean about clear the screen? what screen?

Jx_Man 987 Nearly a Senior Poster Featured Poster

You can change the width or height of controls and follow the form width or height.
Use Form resize event to make it works.
Eg :

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        TextBox1.Width = Me.Width - 40
    End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

what I will to do is to omitt those 04-26
in the lstdata box
and fill txtboxes with corespending text from database

I'm confused here.
What is in listdata1? What is the format item on lstdata1?
This is your format MyDay SPACE eftn SPACE Namn
LstData1.AddItem myDay & " " & rs("eftn") & " " & rs("Namn")
But in your last reply lstdata1 not contain all of it.

When you querying data from database what it the constrains? i mean the fields like eftn or namn.
Write your query here to make me more understand what the constraint.
You want to remove 04-26 and just get the string after it?
ex :
04-26 cesar --> will get cesar
04-26 en sture --> will get en sture

Also what is the use of the string?

Jx_Man 987 Nearly a Senior Poster Featured Poster

the datagrid is bound

You can use SUM function to get total amount.
select sum(amount) as TotalAmount from TableName

Jx_Man 987 Nearly a Senior Poster Featured Poster

See this :

Set rs = db.OpenRecordset("select * from phone where eftn + ' ' + namn = '" & _
Trim(LstData1.List(LstData1.ListIndex)) & "'")

Your sql query is wrong.
You want to display data in textbox when you select listbox but you never get eftn and namn value from listbox.
Also there are no AND clause between eftn and namn

Since you separate data in lisybox with space then you can split it using space to get eftn and namn value
LstData1.AddItem myDay & " " & rs("eftn") & " " & rs("Namn")

So, split selected item on listbox before querying it to database :

    Dim temp() As String
    temp = Split(LstData1.List(LstData1.ListIndex), " ") ' spliting by space

    ' temp(1) will contain eftn from listbox and temp(2) will contain namn from lisbox
    Set rs = db.OpenRecordset("SELECT * FROM phone WHERE eftn = '" & temp(1) & "' AND namn = '" & temp(2) & "'"

    ...
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

        Dim temp As Long = 0
        For i = 0 To DataGridView1.Rows.Count - 1
            temp = temp + DataGridView1.Item(6, i).Value 'Column 6 is Amount
        Next
        Total.Text = temp
Jx_Man 987 Nearly a Senior Poster Featured Poster

DLP/001/2013-2014
DLP/002/2013-2014
DLP/003/2013-2014

I don't recomended to make autonumber to an Id like this but you can split it.
Get the Last Invoice number from database and Split it by "/". Extract the second value in array and you will get the existing invoice num. Add it by 1 and there are new Invoice Num.
Ex :

Private Sub InvoiceNum()
    Set rs = New ADODB.Recordset
    ' Select last row data using MAX() function
    rs.Open "SELECT max(Id)from Address", Conn, adOpenDynamic, adLockBatchOptimistic

    Dim temp() As String
    temp = Split(rs.Fields(0), "/") 'Split data by "/" sign
    ' temp (0) will contain DLP
    ' temp (1) will contain 003
    ' temp (2) will contain 2013-2014

    MsgBox "DLP/00" & temp(1) + 1 & "/2013-2014" ' Show new invoice number 
    rs.Close
End Sub
ITKnight commented: . +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :
SendKeys "%s"

Read this for more information

Sawamura commented: Good link +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

As TnTinMN suggested. You can try AlternatingRowsDefaultCellStyle. The value for alternating rows overrides the value for all rows.

Just two lines code :

    DataGridView1.RowsDefaultCellStyle.BackColor = Color.LightBlue  'Or you can use: DataGridView1.DefaultCellStyle.BackColor = Color.LightBlue
    DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LemonChiffon
Estella commented: Great example +4
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

MsgBox Mid$(Text1.Text, 1, 4)
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

    For i As Integer = 0 To DataGridView1.RowCount - 1
        If DataGridView1.Rows(i).Index Mod 2 = 0 Then
            DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
        Else
            DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LemonChiffon
        End If
    Next i
TnTinMN commented: That works, but why not use AlternatingRowsDefaultCellStyle? +8
Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome.
Don't forget to mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I wanted to know if there was a tidy way of starting from column 1 to begin with

Remove one column when form load.

Private Sub Form_Load()
    DataGrid1.Columns.Remove 0
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Set textbox MaxLength when form load or you can set MaxLength in textbox Properties :

Private Sub Form_Load()
Text1.MaxLength = 2
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

but wat do u mean have an extra row.

Extra row for placing sum of amounts.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I will recommend you to use ADODB method. It's more easy to handling database path and connection with database.

Jx_Man 987 Nearly a Senior Poster Featured Poster

@tope.felix.1 : make your own thread. don't hijack other thread.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :
Add 1 Command Button to your form.
Add 1 reference to Microsoft Excel 12.0 Object Library
Project -> References -> mark the Microsoft Excel 12.0 Object Library

Private Sub Command1_Click()

    Dim xlApp As Excel.Application
    Dim xlWB As Excel.Workbook
    Dim xlWS As Excel.Worksheet

    Set xlApp = New Excel.Application
    Set xlWB = xlApp.Workbooks.Add
    Set xlWS = xlWB.Worksheets.Add

' This following lines will fill the cell (2,2) with the text "hello",
' and will fill the cell (1,3) with the text "World"
    xlWS.Cells(2, 2).Value = "hello"
    xlWS.Cells(1, 3).Value = "World"

' The following line saves the spreadsheet to "c:\mysheet.xls" file.
    xlWS.SaveAs "D:\mysheet.xls"
    xlApp.Quit

' Free memory
    Set xlWS = Nothing
    Set xlWB = Nothing
    Set xlApp = Nothing

End Sub
Naruse commented: agree +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

Private Sub Command1_Click()
If Dir$("D:\Daniweb\", vbDirectory) = "" Then
    MkDir "D:\Daniweb\"
Else
    MsgBox "Duplicate Folder"
End If
End Sub

Private Sub Command2_Click()
If Dir$("D:\Daniweb\", vbDirectory) = "" Then
    MsgBox "Folder not found"
Else
    RmDir "D:\Daniweb\"
End If
End Sub
Aurax commented: Help me too +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

You can post your project in zip with clicking Files in this editor.
Feel free to post. We'll trying to help you.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Then try to change SavingSalaryDetails to viruses_analysis.

Jx_Man 987 Nearly a Senior Poster Featured Poster

It still does not work Jx.it's like replacing the declared variable selectedItem with x right?

Ah..I didn't realized it but the code works fine to me.
What errors is came up?

Also you can try change his :
Dim selectedItem As Integer = ListView1.SelectedItems(0).Index
or
Dim selectedItem As Integer = ListView1.SelectedIndices.Item(0)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :
str = "DELETE FROM AdigratT WHERE Bridge_Number = '" & ListView1.Items(x).SubItems(0).Text & "'"

Jx_Man 987 Nearly a Senior Poster Featured Poster

I change "ID" as "No" in my project. So, user can be easily know how many rows are there.

Why you don't count listview items to show it? it's more easy than user have to drag over the 1000 lines of records.

You know I need to update row "No" and "Background Color" Whenever user deletes any row

No one of control (datagrid,listview,flexgrid,etc) can't handling "No" update. When you remove 1 record, it will completely remove entire data in selected row.

I also add "Edit" button to update one of the fields.When user finish the editing, I will change the background color for related rows.

You can manipulate forecolor and bold to mark edited rows.

There is new codes for what you wants :
You can delete any rows without worrying the number of records.
After editing selected row will change forecolor to Red and set as Bold

Private Sub SetListview()
' Set listview
With ListView1
    .View = lvwReport
    .FullRowSelect = True
    .ColumnHeaders.Add , , "Id", 1100
    .ColumnHeaders.Add , , "First Name", 1400
    .ColumnHeaders.Add , , "Last Name", 1400
    .ColumnHeaders.Add , , "Email", 1700
End With

' Insert Data
With ListView1.ListItems
    .Add , , "1"
    .Item(1).SubItems(1) = "Andre"
    .Item(1).SubItems(2) = "White"
    .Item(1).SubItems(3) = "Andre@White.com"

    .Add , , "2"
    .Item(2).SubItems(1) = "Danny"
    .Item(2).SubItems(2) = "Burnett"
    .Item(2).SubItems(3) = "Danny@Burnett.com"

    .Add , , "3"
    .Item(3).SubItems(1) = "Edward"
    .Item(3).SubItems(2) = "Carter"
    .Item(3).SubItems(3) = "Edward@Carter.com"

    .Add , , "4"
    .Item(4).SubItems(1) = "Anne"
    .Item(4).SubItems(2) = "Witter"
    .Item(4).SubItems(3) …
Jade_me commented: This is awesome dude..wan't to try it.. +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Make sure you have one more row for sum of amount

Try :

    Dim temp As Integer
    temp = 0

    For i = 1 To MSFlexGrid1.Rows - 1
        temp = temp + Val(MSFlexGrid1.TextMatrix(i, 4))
    Next i

    'set sum of amount to last row
    MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = temp

af5176f21877f429286df1edb1c3361b

november_pooh commented: Nice +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

But, "ID" and "background color" are difficult to maintain (match) after deleting all selected item.

Don't use ID since ID didn't related to any data and the code will remove all data in selected row.

For background color don't mind it so much. when you load over 1000 lines of text file it will completely cover the white rows.

Jx_Man 987 Nearly a Senior Poster Featured Poster

How do you change the color of "Main Form's Border"?

I'm not change it. I used win7 and that is win7 themes.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Which version are you using?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Is it possibe to add "Vertical scrollbar" in ListView because data read from file is very huge?

It will added automatically (vertical scrollbar or horizontal scrollbar) when data is more longer than listview.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome.
Don't forget to mark this thread as solved, it will help another members who has same problem like you.

thank you

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

Private Sub ListView1_Click()
    Dim a, b, c, d As String
    Dim index As Integer

    index = ListView1.SelectedItem.index

    a = ListView1.ListItems(index).Text
    b = ListView1.ListItems(index).SubItems(1)
    c = ListView1.ListItems(index).SubItems(2)
    d = ListView1.ListItems(index).SubItems(3)

    'Set textboxes in form2 with value from listview
    Form2.Text1.Text = a
    Form2.Text2.Text = b
    Form2.Text3.Text = c
    Form2.Text4.Text = d

    Form4.Show
End Sub
november_pooh commented: Great +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

If I want to leave the date field blank, would that be a "NULL", or is there another entry that should be used?

You can use SqlDateTime.Null.
Read this : http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqldatetime.null%28v=vs.80%29.aspx

Dim DateVal As SqlDateTime
DateVal = SqlDateTime.Null
cmd.Parameters("@Date").Value = DateVal

Also, since this is entered into a textbox, is there a date conversion that is required to write this to the data table?

cmd.Parameters("@Date").Value = DateTime.Parse(txtDate.Text)

Jx_Man 987 Nearly a Senior Poster Featured Poster

the link you gave there , it has a code there.. is that used in linking the database to the frontend?

Yes, a code for linking vb6 with Mysql but just few lines.
This is an example of connection vb6 with mysql:

Dim Conn As New ADODB.Connection
Dim ConnString As String
Dim db_name As String
Dim db_server As String
Dim db_port As String
Dim db_user As String
Dim db_pass As String

' fill the variable
db_name = "Address"
db_server = "localhost" '
db_port = "3306"    'default port is 3306
db_user = "root"    'default user name.
db_pass = ""  ' depend on your password on mysql
'/Create connection string
ConnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_user & ";PWD=" & db_pass & ";PORT=" & db_port & ";OPTION=3"
'/Open Connection
With Conn
    .ConnectionString = ConnString
    .Open
End With

but in our class , they linked it without any code , an excerpt from my notes says

Yes, you can connect to mysql without code but using code and variable make your program flexible and can run in any computers.

Jx_Man 987 Nearly a Senior Poster Featured Poster

in college , the backend sql is being implemented with oracle 9i , how much does it change things if i use mysql? sorry if the questions are vague ... i dont really know much about vb or sql.. lot to learn.

Not much change. The point is you already learn SQL Language and it's not different when you use oracle or MySql.
Most important is approching method to access database.

http://www.daniweb.com/software-development/visual-basic-4-5-6/threads/436793/tutor-create-register-form-with-vb-6.0-and-mysql-

can you suggest a few good books too?

i'm Sorry, i learning vb from net

Jx_Man 987 Nearly a Senior Poster Featured Poster

I have a college project related to creating banking software where vb6 is being used as the frontend

You can learn about add,update and delete data from database.
Also Encrypt and decrypt data.

if the members could guide me to some good books/links that would be great! looking forward to a good time with vb. :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

1.Read this
2. You can compare date function using DateTime.Compare(date1, date2)
Ex :

    Dim date1 As Date = #08/01/2009 12:00AM#
    Dim date2 As Date = #08/01/2009 12:00PM#
    Dim result As Integer = DateTime.Compare(date1, date2)
    Dim relationship As String 

    If result < 0 Then
       relationship = "is earlier than" 
    ElseIf result = 0 Then
       relationship = "is the same time as"          
    Else
       relationship = "is later than" 
    End If

    Console.WriteLine("{0} {1} {2}", date1, relationship, date2)
    ' The example displays the following output: 
    '    8/1/2009 12:00:00 AM is earlier than 8/1/2009 12:00:00 PM

More info : MSDN and this article

3.It's depend on your region. By default, the date format for SQL server is in U.S. date format MM/DD/YY.
Read this

Jx_Man 987 Nearly a Senior Poster Featured Poster

This Following code is using listview to make background colour and delete multiple items.

Private Sub SetListview()
' Set listview
With ListView1
    .View = lvwReport
    .FullRowSelect = True
    .ColumnHeaders.Add , , "Id", 1100
    .ColumnHeaders.Add , , "First Name", 1400
    .ColumnHeaders.Add , , "Last Name", 1400
    .ColumnHeaders.Add , , "Email", 1700
End With

' Insert Data
With ListView1.ListItems
    .Add , , "1"
    .Item(1).SubItems(1) = "Andre"
    .Item(1).SubItems(2) = "White"
    .Item(1).SubItems(3) = "Andre@White.com"

    .Add , , "2"
    .Item(2).SubItems(1) = "Danny"
    .Item(2).SubItems(2) = "Burnett"
    .Item(2).SubItems(3) = "Danny@Burnett.com"

    .Add , , "3"
    .Item(3).SubItems(1) = "Edward"
    .Item(3).SubItems(2) = "Carter"
    .Item(3).SubItems(3) = "Edward@Carter.com"

    .Add , , "4"
    .Item(4).SubItems(1) = "Anne"
    .Item(4).SubItems(2) = "Witter"
    .Item(4).SubItems(3) = "Anne@Witter.com"

    .Add , , "5"
    .Item(5).SubItems(1) = "Vicky"
    .Item(5).SubItems(2) = "Myron"
    .Item(5).SubItems(3) = "Vicky@Myron.com"
End With
End Sub

Private Sub MakeItColorful(lstview As ListView)
If lstview.ListItems.Count > 0 Then

    picBG.Width = lstview.Width
    picBG.Height = lstview.ListItems(1).Height * (lstview.ListItems.Count)
    picBG.ScaleHeight = lstview.ListItems.Count
    picBG.ScaleWidth = 1
    picBG.DrawWidth = 1
    picBG.Cls
    For i = 1 To lstview.ListItems.Count
        If (lstview.ListItems(i) Mod 2) = 0 Then
            picBG.Line (0, i - 1)-(1, i), &H80FFFF, BF
        Else
            picBG.Line (0, i - 1)-(1, i), &HC0FFC0, BF
        End If
    Next i

    lstview.Picture = picBG.Image
Else
    picBG.Cls
    lstview.Picture = picBG.Image
End If
End Sub

Private Sub Command1_Click()
    With ListView1
        For i = .ListItems.Count To 1 Step -1
            If .ListItems(i).Selected Then
                .ListItems.Remove (.ListItems(i).Index)
            End If
        Next
    End With

End Sub

Private Sub Form_Load()
With ListView1
    .GridLines = True
    .View = lvwReport
End With

SetListview
MakeItColorful ListView1

End Sub

825db81dd0b779fc92e89e8d34ec3404

Jx_Man 987 Nearly a Senior Poster Featured Poster

'is there any code like this?
userform1.input_date.value = userform1.input_date.lastValue

Nope.. I don't think it exist

i have a form and i have 2 input box.
Is there any way to restore the last input in reopening the Form.

You can save it into text file and access it whenever you need

Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

Is it possible to select multiple records (rows) in "DataGrid"

Because I can't find any properties to enable for multiple selection.

Yes.. Just press ctrl while you selecting items.

delete all selected items?

I not sure you can do this. Your code just remove bookmark not remove the items.
Datagrid currently using for displaying data from database.

I didn't use database in my application.

Why not use listview instead of datagrid?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Dim com1 As New OleDb.OleDbCommand
com1 = con1.CreateCommand
com1.CommandText = "insert into Department(DNo,DName,Manager,AddressL1,AddressL2,City,Telephone,E-mail)values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "' )"
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    w = Picture1.Point(X, Y)
    R = w And RGB(255, 0, 0)

    G = Int((w And RGB(0, 255, 0)) / 256)
    B = Int(Int((w And RGB(0, 0, 255)) / 256) / 256)
    labelR.Caption = R
    labelR.Caption.Text = G
    labelR.Caption.Text = B
End Sub
Naruse commented: Thank you :) +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

where can i put table headers, this code will loop on selected record on the table

Just add one row when you create a table.
Set SIATable = SIADoc.Tables.Add(SIADoc.Bookmarks("\endofdoc").Range, rs.RecordCount + 1, 7)

Fill first row with Column name before you get a data thorugh the looping.

        '....

        ' heading
        SIATable.Cell(0, 1).Range.Text = "Column 1"
        SIATable.Cell(0, 2).Range.Text = "Column 2"
        SIATable.Cell(0, 3).Range.Text = "Column 3"
        SIATable.Cell(0, 4).Range.Text = "Column 4"
        SIATable.Cell(0, 5).Range.Text = "Column 5"
        SIATable.Cell(0, 6).Range.Text = "Column 6"
        SIATable.Cell(0, 7).Range.Text = "Column 7"

        ' Fill other rows with data from database
        For siar = 2 To rs.RecordCount + 1
            siac = 1 To 7
                SIATable.Cell(siar, siac).Range.Text = rs(siac - 1).Value
                SIATable.Rows(siar).Range.Font.Size = 9
                SIATable.Rows(siar).Range.Font.Bold = False
            Next
        .MoveNext
        Next

how can i add date and time on the filename: SIADoc.SaveAs ("C:\Users\2mhzbrain\Desktop\Main Inventory - '"& DATE + TIME &"'.docx") this is not working, but this is what i want to happen on the file names. thanks

You can't do it with date and time.
Date and Time will return illegal string for file name.
Date = 4/2/2013
TIme = 12:36:53 PM
Windows will reject this character: \/:*?"<>

Jade_me commented: Nice. +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Selectedrow need you to select full row.
In datagridview properties, change datagridview SelectionMode to FullRowSelect.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You must select it using sql query