Jx_Man 987 Nearly a Senior Poster Featured Poster
Dim conn As New SqlConnection("ConnectionStringGoesHere")
    Dim cmd As New SqlCommand
    conn.Open()
    cmd.Connection = conn
    cmd.CommandText = "Delete From bookings where Bk_id = " & CInt(datagridView1.Item(0,datagridView1.CurrentRow.Index).Value.ToString)
    cmd.ExecuteNonQuery()
    conn.Close()
Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome. :D
Don't forget to mark this thread as Solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Why you don't put it in one form_load?
Make a procedure or function for each code and call it on form_load.

Private Sub waveform_picture_code ()
  'waveform picture code
End Sub
Private Sub rfid_code ()
  'rfid code
End Sub
Private Sub Form_Load()
    waveform_picture_code
    rfid_code
End Sub
alapeh commented: useful and work! +0
Naruse commented: Good +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

What you mean two form load work together? these two from load are coming from same Form or different Form?

Jx_Man 987 Nearly a Senior Poster Featured Poster

You can set radio button checked as True in Radio button properties.
Or you can set it manually :

RadioButton1.Checked = True 'RadioButton1 set as default
    Combobox1.SelectedIndex = 0 'First item of combobox set as default
huskarit commented: Very nice! thanks Jx_Man +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help.
This following code will merge multiple text files into one file :
Add reference : Microsoft Scripting Runtime

Private Sub ConcatenateFiles(ByVal ResultFile As String, ByVal Separator As String, ParamArray SourceFiles() As Variant)
    Dim FSO As New FileSystemObject
    Dim fsSourceStream As TextStream
    Dim fsResStream As TextStream
    Dim sSeparator As String
    Dim i As Integer
    On Error Resume Next
    ' create a new file
    Set fsResStream = FSO.OpenTextFile(ResultFile, ForWriting, True)
    ' for each source file in the input array
    For i = 0 To UBound(SourceFiles)
        ' add the separator first (replacing the special tag for the file path)
        sSeparator = Replace(Separator, "#FilePath#", SourceFiles(i))
        fsResStream.Write sSeparator & vbCrLf
        ' open the file in read mode
        Set fsSourceStream = FSO.OpenTextFile(SourceFiles(i), ForReading)
        ' add its content + a blank line to the result file
        fsResStream.Write fsSourceStream.ReadAll & vbCrLf
        ' close this source file
        fsSourceStream.Close
    Next i
    fsResStream.Close
End Sub

Private Sub Command1_Click()
' Example:
 ConcatenateFiles "D:\res.txt", "------ NEW FILE: #FilePath# ------", "D:\1.txt", "D:\2.txt", "D:\3.txt"
End Sub
Sawamura commented: This is an awosome code :) +3
Estella commented: Absolutely Help +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

It maybe causing by Null return value.

Jx_Man 987 Nearly a Senior Poster Featured Poster

However, I want the values to store into the application and for them to be present when I re-open the application.

What you mean about store into application?
You can save it to text file and load it when application running.
by the way, what is the function of your array? you store values into array then add it into listbox. why you don't add it to listbox directly?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Most of that problem occured is when you try to retieved a data from the database.
Check if the field has the null data or not.

if not isnull(.Fields!Category) then
'[your code]
else
'[your code]
end if
Jx_Man 987 Nearly a Senior Poster Featured Poster

That works! Thanks, but your other code never worked. ( the first post)

You're Welcome. :D
Don't forget Mark this thread as Solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You are missing an

End If

after line 9

wow..really an eagle eyes :D

Jx_Man 987 Nearly a Senior Poster Featured Poster

Add to listbox and sort it. Listbox1.Sorted = true

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi every one. I am having some problem with calculation in datagridview. i have 3 columns in datagridview which are Date,location,Payment. What i want to do now is i want to calculate the total of the payment and my total is a textfield out side the data gridview under the payment field with the label total. This payment is for a specific person who books a photo shoot.suppose when customer 1st comes in the store he pays 30 pounds and second time he pays 20 pounds so total should come up as 50.every time customer comes total for that particular customer should change.please help.Or if possible can some one provide the code

You have 3 columns in datagrid view. You want to calculate payment in column 3 and show it on textbox.

Private Sub DataGridView1_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles DataGridView1.RowsAdded
    Dim temp As Integer
    For i As Integer = 0 To DataGridView1.Rows.Count - 2
        temp += CInt(DataGridView1.Item(2, i).Value.ToString)
    Next i
    TextBox1.Text = temp
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Line 341 is causing the error:

that this code

Document.SelectionFont = New System.Drawing.Font(fontSelection.Text, Document.SelectionFont.Size, Document.SelectionFont.Style)

In your first post, you have two comboboxes for Font name and font size.
You said that you want to select a font size from combo box and apply it to richtextbox. But i didn't see it in your code. Did you tried my code?

Document.SelectionFont = New Font(ComboBox2.SelectedItem.ToString, CInt(ComboBox1.SelectedItem.ToString), Document.SelectionFont.Style)
Jx_Man 987 Nearly a Senior Poster Featured Poster

It cause your "rsLibrary" is not defined.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim btn As Control
        For Each btn In Me.Controls
            If TypeOf btn Is Button Then
                btn.ForeColor = Color.Blue
            End If
        Next
    End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

how to transfer all items of a list box to another list box in vb?

In .Net you can use AddRange function of listbox.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ListBox2.Items.AddRange(ListBox1.Items)
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    RichTextBox1.SelectionFont = New Font("Tahoma", CInt(ComboBox1.SelectedItem.ToString), RichTextBox1.SelectionFont.Style)
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

You're welcome. :D
Don't forget to mark this thread as solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Your code is fine. you just need to hide textboxes when form load. So, when your checkbox checked it will be visible :

private void Form1_Load(object sender, EventArgs e)
     {
        textBox4.Visible = false;
        textBox5.Visible = false;
     }
private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (checkBox1.Checked)
        {
            textBox$.Visible = true;
            textBox5.Visible = true;
        }
        else
        {
            textBox4.Visible = false;
            textBox5.Visible = false;
        }
    }
Jx_Man 987 Nearly a Senior Poster Featured Poster

An example :

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    Dim i As Integer = DataGridView1.CurrentRow.Index
    With DataGridView1
            If DataGridView1.Item(0, i).Value = "1" Then
                textbox1.text="hello"
            End If 
    End With
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Easiest way is using timer control.

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

It because there is no SubItems(3) in your listview..
And why you show Owner ID twice in all of your codes?
modified as following "

Set lst1 = lvStudentInfo.ListItems.Add 
        With lst1
            .Text = rs!Owner_ID
            .SubItems(1) = rs!Owner_Name
            .SubItems(2) = rs!Owner_Address
          
        End With
Jx_Man 987 Nearly a Senior Poster Featured Poster

when i click on the command botton then it will show a
Run time error 52
if we delete this line to my coding
Err.Raise 52
then it will show Message (Msgbox "File recycled")
but cannot delete my file
please send me again code here is some problem so please tell me
what's wrong
what i do ?
Thanks

I'm sorry, I forgot to mention you to add reference.
Project-> Reference -> Microsoft Shell Controls and Automation
Also make sure that your files is exist.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome. :D
Dont forget to marh this thread solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Thanks Jx man
i am very thanks full to you.
you solve my problems many time. so Thanks you are a Genius.
Thanks alot

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
commandString = "Select * from tableadd where " + this.comboBox1.SelectedText + "like '%" + textBox1.Text + "%'" ;

Your code should be correct. Try to add space before like statement.

commandString = "Select * from tableadd where " + this.comboBox1.SelectedText + " like '%" + textBox1.Text + "%'" ;
skatamatic commented: Looks like the OP forgot to +1 you +9
Jx_Man 987 Nearly a Senior Poster Featured Poster

Ooops! i tried to upload the code with everything :-)
But i forgot i can't :-) okay i will post the code and
then the controls needed.

Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
List4.AddItem List1.List(i) & List2.List(i) & List3.List(i)
Next i
End Sub
Private Sub Command4_Click()
List4.Clear
Dim strLine() As String
Dim i As Integer
strLine() = Split(Text3.Text, vbCrLf)
For i = 0 To UBound(strLine)
List2.AddItem strLine(i)
Next
Label3.Caption = CStr(List2.ListCount)
End Sub
Private Sub Command5_Click()
Dim i As Long
Open App.Path & "\" & "Ok.txt" For Output As #23
For i = 0 To List4.ListCount - 1
Print #23, List4.List(i)
Next i
Close #23
End Sub
Private Sub Form_Load()
Me.Icon = Nothing
End Sub
Private Sub Command2_Click()
List1.AddItem Text1
Label1.Caption = CStr(List1.ListCount)
List3.AddItem Text2
Label2.Caption = CStr(List3.ListCount)
End Sub

1.) Form1
2.) Label1, Label2, Label3.
3.) Textbox1, Textbox2, Textbox3.
4.) Listbox1, Listbox2, Listbox3, Listbox4.
5.) CommandButtom1, CommandButtom2, CommandButtom3, CommandButtom4.

Thats it

Good job C0ding and Thank you for sharing.
Enjoy daniweb :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

Oh wait! i was not aware of this :-)
Thank you! let me try and see how it works!
Thank you again

Okay. Try it and give a feedback.
If you already managed it then post your code and mark this thread as solved.
It will help another member who has same problem like you. :)
Thank you.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay since you need to copy-paste text in textbox 2, then i rewrite this code.
I assume you have 3 textboxes and 1 listbox to join all text.
Try this :

Private Sub Command2_Click()
    Dim myParas As Variant
    Dim i As Integer
    myParas = Split(Text2, vbNewLine)
    
    Dim a() As String
    a = Split(Text2, vbNewLine)

    For i = 0 To UBound(myParas)
        List1.AddItem Text1.Text & a(i) & Text3.Text
    Next
End Sub
Vega_Knight commented: Nice Code :D +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

what you mean exactly?
you want to use textbox instead of listbox?

Jx_Man 987 Nearly a Senior Poster Featured Poster

use timer control. Set Enable as True in timer properties

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Label1.Text = Now
End Sub
Begginnerdev commented: Beat me to it. :) +5
Jx_Man 987 Nearly a Senior Poster Featured Poster

but when i'm trying to input grades for the other student i can't save the grade but there is no error shown

.
it cause you using "On Error Resume Next" statment on line 2.
Delete this line and you will know what the error is if error detected.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Sub EnumFolders(fld As Object)
   Dim oShell As Object, fldItem As Object
   Dim i As Long
   On Error Resume Next
   Set oShell = CreateObject("Shell.Application")
   For Each fldItem In fld.Items
       If fldItem.IsFolder Then
          Call EnumFolders(fldItem)
       End If
       list1.AddItem fld.GetDetailsOf(fldItem, 0)
       
   Next
   Set fldItem = Nothing
   Set fld = Nothing
   Set oShell = Nothing
End Sub

Private Sub Command1_Click()
Dim oShell As Object
   Dim oRecycler As Object
   Set oShell = CreateObject("Shell.Application")
   Set oRecycler = oShell.NameSpace(10)
   EnumFolders oRecycler
End Sub
Naruse commented: Amazing... +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

API Declare :

Option Explicit

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
 
Private Type SHFILEOPSTRUCT
    hwnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Long
    hNameMappings As Long
    lpszProgressTitle As Long
End Type
 
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SILENT = &H4

Private Sub ShellDeleteOne(sFile As String)
 
  'set some working variables
   Dim shf As SHFILEOPSTRUCT
 
  'terminate the file string with
  'a pair of null charss
   sFile = sFile & vbNullChar & vbNullChar
 
  'set up the SHFile options
   With shf
      .wFunc = FO_DELETE  'action to perform
      .pFrom = sFile      'the file to act on
      .fFlags = 0& ' Delete permanent
      .fFlags = .fFlags + FOF_NOCONFIRMATION ' No confirm to delete
      .fFlags = .fFlags + FOF_SILENT
   End With
 
  'perform the delete
   Call SHFileOperation(shf)

End Sub

Delete File :

Private Sub Command1_Click()
    Call ShellDeleteOne("D:\junk.txt")
End Sub

Delete Folder :

Private Sub Command1_Click()
    Call ShellDeleteOne("D:\junk")
End Sub

Delete All Files (folders n files) in folder junk

Private Sub Command1_Click()
    Call ShellDeleteOne("D:\junk\*.*")
End Sub
Asitha_1 commented: Working correctly.. Thanks.. +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

Set KeyPreview as True on form properties.
Then add this following code :

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'make sure KeyPreview is True on Form Properties
    'On Error Resume Next
    Select Case KeyCode
        Case vbKeyUp
            MsgBox "Up"
        Case vbKeyDown
            MsgBox "Down"
        Case vbKeyLeft
            MsgBox "Left"
        Case vbKeyRight
            MsgBox "Right"
    End Select
End Sub
luckynisarg commented: Good +0
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Sub Recycle2(ByVal FQFileOrFolder As String)
    'Late bound.
    Dim Delim As Integer
    Dim FItem As Object
    Const ssfBITBUCKET = 10
    
    Delim = InStrRev(FQFileOrFolder, "\")
    With CreateObject("Shell.Application")
        For Each FItem In .NameSpace(Left$(FQFileOrFolder, Delim - 1)).Items
            If Not FItem.IsLink Then
                If UCase$(FItem.Name) = UCase$(Mid$(FQFileOrFolder, Delim + 1)) Then
                    .NameSpace(ssfBITBUCKET).MoveHere FItem
                    Exit Sub
                End If
            End If
        Next
    End With
    Err.Raise 52
End Sub

Private Sub Command1_Click()
    Recycle2 "D:\File.txt"
    Msgbox "File recycled"
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

I assume you use listbox for all controls :
You can use '&' ampersand sign to concatenate all items with same index for every listbox.
See this following code :

Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
    List4.AddItem List1.List(i) & List2.List(i) & List3.List(i) ' add items in list 1,2,3 to list 4
Next i
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

What the problem here?

Jx_Man 987 Nearly a Senior Poster Featured Poster

You can use many ways here..
Here is an example :

Private Sub Save_Click()
    Set Conn = New ADODB.Connection
    Conn.Provider = "microsoft.jet.oledb.4.0"
    Conn.CursorLocation = adUseClient
    Conn.Open App.Path & "\Authors2.mdb"
    
    For i = 0 To List1.ListCount - 1
        Set rs = Nothing
        Set rs = New ADODB.Recordset
        
        rs.Open "SELECT * from Login", Conn, adOpenStatic, adLockOptimistic
        
        rs.AddNew
        rs!Author = List1.List(i) ' add all items on listbox
        rs.Update
    Next i
    MsgBox "Data Added", vbInformation, "Add Data"
    rs.Close
    Conn.Close
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Rename your exe project with system name like services.exe, etc.

Jx_Man 987 Nearly a Senior Poster Featured Poster

How can i improve this code thanks in advance

Your sql statement is not right

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
M.Waqas Aslam commented: nice work +5
Jx_Man 987 Nearly a Senior Poster Featured Poster

Use if-else statement :

If Option1.Value = True Then
    ' Your code if user select radio button 1
ElseIf Option2.Value = True Then
    ' Your code if user select radio button 2
End If
Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay. I made a simply vb project test and it's working.
Also i modified Middle Name searching with "Like" statment. It more usefull in searching.
Just change adodc connection string with your own path.

Hope it helps.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help.

Add a timer, set interval to 1000 (or you can assign as you needed)
And use this following code :

Private Sub Timer1_Timer()
Label1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
Sturdy commented: Perfect +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Well, you need to know what conditions when you have to send sms automatically.
If you already know it then use timer control to check the conditions and send a sms when you get same condition.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Okay Access database.
It seems that you don't want to post your database here.
Then i just can tell you to check your input in text box searching.
Like i said before, you must input same data as recorded in database. Uppercase, lowercase, all letters must be same. If your input didn't same as saved in database then program cannot search it.

Jx_Man 987 Nearly a Senior Poster Featured Poster

thanks, it's help me...
@ jx man, how about using ActiveXpertsToolkit ...???
is that work like sms libx..???

See this.

Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you doing this?
post your code. where the error is. we're going to help you.