Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long,ByVal pszRootPath As String,ByVal dwFlags As Long) As Long
Private Const SHERB_NORMAL = &H10
Private Const SHERB_NOCONFIRMATION = &H1
Private Const SHERB_NOPROGRESSUI = &H2
Private Const SHERB_NOSOUND = &H4
Private Const SHERB_NOALL = _
(SHERB_NOCONFIRMATION And _
SHERB_NOPROGRESSUI And SHERB_NOSOUND)

Dim RetVal As Long
Private Sub Command1_Click()
   Dim y as Integer
   y = MsgBox("Are u sure to clean up Recycle Bin ? ", vbYesNo, "Confirmation"
   If y = vbYes Then
      RetVal = SHEmptyRecycleBin(0&,vbNullString,&H1)
   MsgBox "Recycle Bin has been cleaned"
   End If
End Sub
Vega_Knight commented: Worked Perfectly +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Public Function ChangeFileExt(ByVal FileName As String, ByVal Extention As String)
 Dim str() As String, NewFile As String
 If InStr(1, FileName, ".") Then
     str = Split(FileName, ".")
     NewFile = Replace(FileName, str(UBound(str)), Extention)
     Name FileName As NewFile
 Else
     Name FileName As FileName & "." & Extention
 End If
End Function

Private Sub Command1_Click()
Call ChangeFileExt("D:\test.jx", "txt")
End Sub

Or you can use another technique in this post

Sawamura commented: Awesome!!!! +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Private Sub ListFiles(strPath As String, Optional Extention As String)
'Leave Extention blank for all files'
    Dim File As String

    If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"

    If Trim$(Extention) = "" Then
        Extention = "*.*"
    ElseIf Left$(Extention, 2) <> "*." Then
        Extention = "*." & Extention
    End If

    File = Dir$(strPath & Extention)
    Do While Len(File)
        List1.AddItem File
        File = Dir$
    Loop
End Sub

Private Sub Command1_Click()
    ListFiles "D:\musicfolder", "*" 
    ' Or ListFiles "D:\musicfolder", "" leave it blank to get all files'
End Sub

See this thread

Sawamura commented: Worked nice :) +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub ClearCombo(ByVal MyCombo As ComboBox)
    MyCombo.Clear
End Sub

Private Sub ClearCombo_Click()
Dim Temp As Control
For Each Temp In Me.Controls
    If TypeOf Temp Is ComboBox Then
        Temp.Text = ""
        ClearCombo Temp
    End If
Next
End Sub
Sturdy commented: Solved +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try :

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
    txttID.Text = DataGridView1.Item(0, i).Value
    txttSurname.Text = DataGridView1.Item(1, i).Value
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

To limit your retrieved data from database you use TOP clause in your sql statement.
You can read in this site.

Select TOP 50 * from Customers
Sturdy commented: Worked Perfectly +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Sub FindMySpecificString(ByVal searchString As String)
    ' Ensure we have a proper string to search for.'
    If searchString <> String.Empty Then
        ' Find the item in the list and store the index to the item.'
        Dim index As Integer = listBox1.FindStringExact(searchString)
        ' Determine if a valid index is returned. Select the item if it is valid.'
        If index <> ListBox.NoMatches Then
            listBox1.SetSelected(index, True)
        Else
            MessageBox.Show("The search string did not find any items in the ListBox that exactly match the specified search string")
        End If
    End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    FindMySpecificString(TextBox1.Text)
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Use looping to read all data.

While (acsdr.Read())
ComboBox2.Items.Add(acsdr("Sections"))
End While
november_pooh commented: True +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

I'm really in good mood right now. i write a simple code about how to add data to flexgrid and save it, also load it to flexgrid.
For edit and delete? do it by yourself. since 265 posts you should know about daniweb rules :)

Add references : Microsoft ActiveX Data Object 2.5 Library
Add 2 flexgrid : FlxGrdDemo for input data and FlxGrdDemo2 for load data.
Add 2 button for save and load.

After from load you can see default data in database. Just add new Au_Id and Author in first flexgrid. Use Keyboard Arrow to move and Enter to make new row.

Public Conn As New ADODB.Connection

Private Sub Access_Connector()
    Dim db_file As String

    ' Get the data.'
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
    db_file = db_file & "Authors.mdb"

    Set Conn = New ADODB.Connection
    Conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & db_file & ";" & _
        "Persist Security Info=False"
    Conn.Open
End Sub

Private Sub LoadData()

    Dim c As Integer
    Dim r As Integer
    Dim col_wid() As Single
    Dim field_wid As Single

    Access_Connector ' Connect to access'

    Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Authors", Conn, adOpenDynamic, adLockBatchOptimistic

    ' Use one fixed row and no fixed columns.'
    FlxGrdDemo2.Rows = 2
    FlxGrdDemo2.FixedRows = 1
    FlxGrdDemo2.FixedCols = 0

    ' Display column headers.'
    FlxGrdDemo2.Rows = 1
    FlxGrdDemo2.Cols = rs.Fields.Count
    ReDim col_wid(0 To rs.Fields.Count - 1)
    For c = 0 To rs.Fields.Count - 1
        FlxGrdDemo2.TextMatrix(0, c) = …
Sawamura commented: You should get paid for this codes +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Yes, You need to download the ODBC connector.
Here is the link :
http://dev.mysql.com/downloads/connector/odbc/5.1.html#win32

Naruse commented: Thanks +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

below is my vb6.0 code. the click command is to save my text and picture. there is no problem for my text. but, i have a problem after saving the picture. the picture can be saved but it is not availabe for preview. is there any fix for this ?

To save picture in PictureBox you should use SavePicture() function :

Dim namefile2
namefile = App.Path & ("/" & Text1 + Text2) & ".bmp"
SavePicture Picture1.Image, namefile
dnk commented: :D +1
Neji commented: - +1
debasisdas commented: agree +13
Jx_Man 987 Nearly a Senior Poster Featured Poster

I don't understang what are your trying to do. But seems you want to make a line chart.
Why you don't use Microsoft Chart Control?
Go to Project->Component->Mircrosoft Chart Control 6.0

Jade_me commented: nice assist +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

it does not work! but thank you! i found a way!

Hi huskarit,

Thats great that you found the way to solve your problem.
So, Would you like to share the way you solve it?
It will help another member who has same problem like you. Especially when they read this thread.

Thank You.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
    Unload Me
End If
End Sub
Estella commented: helper +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

like this ?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.Enabled = False
    ComboBox1.Enabled = False
End Sub
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

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

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

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

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

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

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

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

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

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

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

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

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

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
november_pooh commented: Great link +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Anyways, May I ask, where should I insert the msgbox code so that everytime the user enters letters or other numbers except from 1,2 and 3 of course, a pop-up msg will show up telling that he entered "Invalid Code" ?

Put in trapping case :

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57, 8 '0-9 and backspace
        'Let these key codes pass through
        Case Else
        'All others get trapped
        KeyAscii = 0 ' set ascii 0 to trap others input
        MsgBox "Invalid Code" 'Put your message here
    End Select
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Private Sub Command1_Click()
List1.Clear
x = 0
For j = 1 To Len(Trim(Text1.Text))
    kt1 = Mid(Trim(Text1.Text), j, 1)
    kta = kta + kt1
    If kt1 = Chr(32) Then
        x = x + 1
        List1.AddItem Trim(kta)
        kta = ""
    End If
Next j

If x >= 0 Then List1.AddItem Trim(kta)

End Sub
EkoX commented: Worked really nice :D +1
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Dim ctrAs Control

For Each ctr In Me.Controls
   If TypeOf ctr Is TextBox Then
      If ctr.Text= vbNullString Then
         MsgBox "Textbox empty"

         ctr.SetFocus

         Exit Sub

      End If
  End If
Next ctr
hkdani commented: Excellent suggestions based on in depth knowledge of the language. +5
Sturdy commented: It's a wonderful code sir :) +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

when the input is 12 years and 6 months I want the program to print teenager
I'm not sure how to do that

Input should be 12.6 to get right result.
so you can concatenate textbox1 (for year) and textbox2 (for month) :

Private Sub Command1_Click()
Select Case Val(Text1.Text) & "." & Val(Text2.Text)
    Case 0 To 1
        MS_lbl_category.Text = CStr("infant")
    Case 1 To 2
        MS_lbl_category.Text = CStr("toddlerI")
    Case 2 To 6
        MS_lbl_category.Text = CStr("kindergarten")
    Case 6 To 12
        MS_lbl_category.Text = CStr("child")
    Case 12 To 19
        MS_lbl_category.Text = CStr("teenager")
    Case 19 To 25
        MS_lbl_category.Text = CStr("young adult")
    Case 25 To 40
        MS_lbl_category.Text = CStr("adult")
    Case 40 To 60
        MS_lbl_category.Text = CStr("middle aged")
    Case 60 To 120
        MS_lbl_category.Text = CStr("senior citizen")
    Case Else
        MS_lbl_category.Text = CStr("Are you kidding ?")
End Select
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Like i said before to manipulate your SQL Statment :

openrstJCcaseInfo "select * from JCcaseInfo like " & "'%" & txtsearch.Text & "%'"
Estella commented: Good Point :D +4
Vega_Knight commented: :D +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Command1_Click()
    MsgBox Printer.DeviceName
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Just trap the ascii code, So user only can input numbers.
This following code just accept numbers input only :

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57, 8 '0-9 and backspace
        'Let these key codes pass through
        Case Else
        'All others get trapped
        KeyAscii = 0 ' set ascii 0 to trap others input
    End Select
End Sub
ynehs commented: thumbs up! +0
Jx_Man 987 Nearly a Senior Poster Featured Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help :

Shell("shutdown -s") 'Shutdown
Jx_Man 987 Nearly a Senior Poster Featured Poster

This how far i'm doing. But i don't know how to check if last 3 character is number?

Use IsNumeric() function :

Private Sub Command1_Click()
Dim First4Char, Last3Char As String
First4Char = Mid(Text1.Text, 1, 4)
Last3Char = Mid(Text1.Text, 5, 7)
If Len(Text1.Text) <= 7 Then
    If First4Char <> "ABCD" Then
        MsgBox "Wrong"
    Else
        If Not IsNumeric(Last3Char) Then
            MsgBox "Wrong Input"
        Else
            ' Action if text is accepted
        End If
    End If
End If
End Sub
Sturdy commented: It worked very nice. :D +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

You can use Mid() , Left() or Right() function to get The first four characters and the last 3 characters and Use Len() for the length of text.

Jx_Man 987 Nearly a Senior Poster Featured Poster

I mean, when i put cursor (click) in some text i will know where the cursor is.

Okay. See if this helps :

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Text1.SelLength = 0 Then
    lCurPos = Text1.SelStart
Else
    lCurPos = Text1.SelStart + Text1.SelLength
End If
Label1.Caption = "Cursor Position " & lCurPos
End Sub
Sturdy commented: It worked sir. :D +1
Sawamura commented: Good +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

>>what connection will i use and how and sample codes.
You want to connect with access 2007 or you want to make report of your db?
Anyway how far you doing this?