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

Cappucino with apple cake

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

Also dont forget to set recordset as datagrid source. It will link database and datagrid.

Set DataGrid1.DataSource = rs
Jx_Man 987 Nearly a Senior Poster Featured Poster

9 Letters only can be appear in datagridview...

What you mean about 9 letters only?
You mean only first 9 records from your database?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Set this :

DataGrid1.AllowAddNew = True ' This line will add new row on datagrid
DataGrid1.AllowUpdate = True ' this line will let you to add data and edit data directly in datagrid

This line will add data directly to database when you write new data on datagrid

Jx_Man 987 Nearly a Senior Poster Featured Poster

What you got so far?
Post your code here.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Datagridview?
Are you use Vb.Net?
Also what you get so far?
Post your code here. Make some efforts.

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

What's makes me get bad rep here?

Estella commented: Just random member.. take it easy +4
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
ITKnight commented: +1 +2
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

Specify what is Recall.
If recall just string then put double quote around it and confirm the case sensitive input from the textbox.

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

I think for case like dictionary text file is more fast.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

Dim regTime As New System.Text.RegularExpressions.Regex("^([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$")
Dim t1 As String = "25:12:12"
Dim t2 As String = "12:45:34"
Dim t3 As String = "01:12:92"

MsgBox(regTime.IsMatch(t1).ToString)
MsgBox(regTime.IsMatch(t2).ToString)
MsgBox(regTime.IsMatch(t3).ToString)
Jx_Man 987 Nearly a Senior Poster Featured Poster

Is it possible to store Data(Word;Type;Sentence) in textfile and to display in the Listbox and textbox.

Yes, It's possible.

Imports System.IO

    ' This will add Data as new line in txt file.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim writer As StreamWriter
        writer = File.AppendText("D:\Dictionary.txt")
        writer.WriteLine(txtWord.Text & ";" & txtType.Text & ";" & txtSentence.Text)
        writer.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If File.Exists("D:\Dictionary.txt") Then
            Dim openFileLines() As String = File.ReadAllLines("D:\Dictionary.txt")
            ListBox1.Items.AddRange(openFileLines)
        End If
    End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

When write a code you must know what the value of variables.

Label1.Text = "First digit:" & TextBox1.Text.Substring(0, 1)
Label2.Text = "Second digit:" & TextBox1.Text.Substring(1, 1)

Label3.Text = (Label1.Text) ^ 2

Ex : TextBox1 = 12

Now Label1.Text will contain "First digit:1"
So you can't square what in label1 cause it not contain numbers but string.
As Begginnerdev suggest to put value in variables it makes you more easy to handle math operation.

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

App.Path is return path of your program.
It will return path where the project is saved.
Just take a test. Create a new project and display a path of project (Msgbox App.Path) in form load event and save it. It will return path of project. Move the project to another directory and run it again, the part will changed for sure.

Jx_Man 987 Nearly a Senior Poster Featured Poster

thank you sir TnTinMN.

Then mark this thread as solved :)

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