Jx_Man 987 Nearly a Senior Poster Featured Poster

Just give feedback if you have a problem

Jx_Man 987 Nearly a Senior Poster Featured Poster

Change this line (at line # 8):

t = Mid(msg, i, Len(msg))

With this :

t = Mid(msg, i, Len(msg)) + Left(msg, i)

Hope it helps :)

dnk commented: Really helpfull person. +2
Neji commented: Good eyes for this.. +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

i already make it scrolling

Post the code..how far you doing this.

Jx_Man 987 Nearly a Senior Poster Featured Poster

You mean system directory?

See if this helps :

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
    Dim sSave As String, Ret As Long
    sSave = Space(255)
    Ret = GetSystemDirectory(sSave, 255)
    sSave = Left$(sSave, Ret)
    MsgBox "Windows System directory: " + sSave
End Sub
Vega_Knight commented: Perfect +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

data type mismatch in criteria expression,, this is the error.
i tried many times yesterday, if any one please can help me here..
thanks in advance..

Are you copied all the code without change it? i was wrong in type table name "tblEmployees", it must be "SYS_USER". Sorry, my bad.
So, it should like this follwoing line:

If Me.PASSWORD.Value = DLookup("password", "SYS_USER", "[username]=" & Me.Combo0.Value) Then
Jx_Man 987 Nearly a Senior Poster Featured Poster
If Me.PASSWORD.Value = DLookup("password", "tblEmployees", "[username]=" & Me.Combo0.Value) Then
Jx_Man 987 Nearly a Senior Poster Featured Poster

Why not use StrConv()

See if this helps :

Private Sub txtQuote_Change()
  txtQuote.Text = StrConv(txtQuote.Text, vbProperCase)
  txtQuote.SelStart = Len(txtQuote.Text)
End Sub
dnk commented: Very Quckly Response +2
Jade_me commented: :D +2
Naruse commented: Agree +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

hye jan plz explain how can i use Listview? In my project.?

Project -> Component (Ctrl + T)
looking for "Microsoft Windows Common Controls 6.0 (SP6)" and check it.
you can find listview on your toolbox.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hello sir, Yes i want to add new data sir,how could it be sir?

Really, I hope you understand what i mean.

Okay, if you want to add a new data.
Just check if the checkbox is checked then add data with status is Active and if checkbox not checked then add data with status is Not Active.

Private Sub cmdadd_Click()
Dim CheckTemp As String

If chkbox.Value = 1 Then
    CheckTemp = "Active"
Else
    CheckTemp = "Not Active"
End If

sql = "INSERT INTO Customer(Id,User_Name,Family_Name,Status) VALUES('" & txtid.Text & "','" & txtname.Text & "', '" & txtfname.Text & "','" & CheckTemp & "')"
con.Execute (sql)

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi,
You make this thread Unsolved and you ask the different question now..
Please keep the originally question of this thread about how to transfer data from flexgrid.
Also, you already have a new thread about your question.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Listview i think..

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hello sir, Thank you for the reply.I Forgot to put the field.The name of the field in my database is Status,and i want it Active or Not Active.

So i can conclude that you have Id,User_Name,Family_Name and Status on your customer table.

This following quote is your example on your first post :

Jemz Gimz 123 then i will check the checkbox and click the Add button
it should display on my listview
Jemz Gimz 123 Active.

In your example you looks like you want to update/edit current data on the table not to add new data on the table.
So my next question is you want to add fresh data or you want to update/edit a current data on the customer table?

Jx_Man 987 Nearly a Senior Poster Featured Poster

i don't understand correctly.
You want to add it (active or not active) to database or just for temporary only?
Do you have a field for it on database?

Jx_Man 987 Nearly a Senior Poster Featured Poster

This following code to get data from datagrid..

DataGrid1.Row = 0 ' first row.. just looping as many of datagrid rows 
DataGrid1.Columns(0).Value
DataGrid1.Columns(1).Value
DataGrid1.Columns(2).Value
Jx_Man 987 Nearly a Senior Poster Featured Poster

Lets keep originally question of this thread. if this thread already answered please make it solved and if you have a new question please make a new thread. it will help another member when they search a same thread.

Thank you :)

For your question :

can you help me please how can i make the higlight remain if i will set the cursor to the textfield.

Set the HideSelection property of the ListView control to false..

Jx_Man 987 Nearly a Senior Poster Featured Poster
MsgBox temp(0) + vbCrLf + temp(1) + vbCrLf + temp(2) + vbCrLf + temp(3)

You accessing array with this way..
How about if you have many words separated with commas?
Are you want to get all data by write it one by one?
Use looping and Ubound to get last index of array

Private Sub Command1_Click()
Dim temp As Variant
Dim str As String
Dim arr As String
str = "i,love,you,forever"
temp = Split(str, ",")

For i = 0 To UBound(temp) ' get the last index with Ubound
    arr = arr + temp(i) + vbCrLf ' Read data until last index and store it on arr
Next i
MsgBox arr ' display it on message box
End Sub
Naruse commented: You enlighten me so much sir..Thank you :) +3
dnk commented: good point. +2
november_pooh commented: Good Point here.. :D +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

use split function.

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps.

Actually when you add data it added in the last.
So, you just simply select the last data on listview :

Private Sub cmdadd_Click()

sql = "INSERT INTO Customer(id,Name,familyName,Address) VALUES('" & lngId & "','" & txtname & "', '" & txtfamilyname & "','" & txtaddress & "')"
con.Execute sql
 
GetData lvwIP

' Select a newly data added start here
ListView1.ListItems(ListView1.ListItems.Count).Selected = True ' select the last data on list view and set it as true
ListView1.SetFocus ' set focus on listview
ListView1.FullRowSelect = True ' full row selected

End Sub

But if you don't sure if data not added on last index then use this following code :

Private Sub cmdadd_Click()
' Declared variable
Dim itm As ListItem 
Dim strSearch As String
Dim x As Integer
 
sql = "INSERT INTO Customer(id,Name,familyName,Address) VALUES('" & lngId & "','" & txtname & "', '" & txtfamilyname & "','" & txtaddress & "')"
con.Execute sql
 
GetData lvwIP

' Select a newly data added start here
strSearch = Text1.Text

For Each itm In ListView1.ListItems ' search for all list item on listview
    If itm.Text = strSearch Then ' assign if item = strsearch
        x = itm.Index ' get the index of founded item
        ListView1.ListItems(x).Selected = True ' Highlight the row
        ListView1.SetFocus ' set focus on listview
    End If
Next
ListView1.FullRowSelect = True ' full row selected

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Use Format function to make it right aligned.
Also change textbox font to Courier New.

Private Sub Command1_Click()
Dim GRN As Integer
With FGRID1
    For GRN = 1 To .Rows - 1
        Text6.Text = Text6.Text & vbCrLf & .TextMatrix(GRN, 0) & vbTab & _
        Format$(Format$(.TextMatrix(GRN, 2), "##0.00"), "@@@@@@@@@@@@@")

    Next i
End With
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

see this site for adOpenstatic explaination
Don't Forget to mark this thread as solved :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

You're Welcome.
Don't Forget to mark this thread as solved.
Happy Coding ;)

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Dim i, Count As Integer

Count = 0

i = InStr(i + 1, Text1.Text, "How")
If i = 0 Then
    MsgBox 0
    Exit Sub
End If

Do While i > 0
    i = InStr(i + 1, Text1.Text, "How")
    Count = Count + 1
Loop

MsgBox Count
dnk commented: Thanks +2
ITKnight commented: Nice code +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you doing this?
Post the code that you've been work.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Sorry for that, my Bad.
Declare view as list item :

Dim view As ListItem
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this following code to display data from access :

Private Sub GetData(LSV As ListView)
Call ColumnName(lvwIP, "Name", 40, "Family Name", 30, " Address", 40)
            
    Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Customer", Con, adOpenStatic, adLockOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!Name
        View.SubItems(1) = rs!familyName
        View.SubItems(2) = rs!Address
       
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Call GetData after insert data :

Private Sub cmdadd_Click()

 Dim lngId As Long
 
 lngId = GenNextID
  

 sql = "INSERT INTO Customer(id,Name,familyName,Address) VALUES('" & lngId & "','" & txtname & "', '" & txtfamilyname & "','" & txtaddress & "')"
 con.Execute sql

GetData lvwIP ' Call here to update listview

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

You have procedure to display it..ColumnName..just call after insert data.

Private Sub cmdadd_Click()

 Dim lngId As Long
 
 lngId = GenNextID
  

 sql = "INSERT INTO Customer(id,Name,familyName,Address) VALUES('" & lngId & "','" & txtname & "', '" & txtfamilyname & "','" & txtaddress & "')"
 con.Execute sql

Call ColumnName(lvwIP, "Name", 40, "Family Name", 30, " Address", 40) ' Call here to update listview

End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

How far you doing this?
Post your code, we try to help :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

So you want to get data from grid to One Textbox only?
Post your code how far you doing this?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hello,


Please help me, how can i populate or display my newly added list in the listview, if i will click my addbutton.can you please help me.

Thank you in advance and I am hoping for your positiver response.

Hi,
Are you can display data on listview?
What database are you using?

Jx_Man 987 Nearly a Senior Poster Featured Poster

Show us your effort. how far you doing this?
Just post your code and we try to helps you.

Jx_Man 987 Nearly a Senior Poster Featured Poster

is it necessary to make an array in displaying the column header in the listview?

Not necessary too. I make this code for flexibility purpose. so, you don't have to create new code for new header. just change the parameters on array when you call it. But, if you don't have many list view to set or if your headers is never change then it's not necessary to use array.
You can use this simply following code to add header without array :

With ListView1
    .View = lvwReport ' make listview looks like report view
    .ColumnHeaders.Clear ' Clear header
    .ColumnHeaders.Add , , "First Name", 2000 ' Add header name n width
    .ColumnHeaders.Add , , "Last Name", 2000 ' Add header name n width
    .ColumnHeaders.Add , , "Address", 3000 ' Add header name n width
End With

sir can i ask with you where did you get idea on this or what reference book did you use sir?

i coded this procedure when i was in college and i don't have any reference book.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Hi Zeb noon,
Please post your new question on new thread, with new title. you can get many helps from other members and gurus in new thread. i will help you there too.
Just keep the this thread for your originally question.
And Don't Forget to Mark This Thread As Solved.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Use Mid function to search space in text box:

Private Sub Command1_Click()
Dim Counts As Integer
If Text1.Text = "" Then
    Counts = 0
Else
    Counts = 1
    For i = 1 To Len(Text1.Text)
        If Mid(Text1.Text, i, 1) = " " Then ' use Mid to search space
            Counts = Counts + 1
        End If
    Next
End If
MsgBox Counts
End Sub
WaltP commented: Why do you insist on doing their homework? -3
dnk commented: Thanks for Mid function +2
november_pooh commented: Usefull +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

i need to run program when computer starts. i m trying this

Shell "schtasks /create /sc onstart/tn autoonoff/tr D:\old files\Vb Projects\Auto Shut n Restart\Project1.exe"

i m administrator but want to make this for both administrator and user. operating system where this program will run is Xp sp2

you using shell code in vb code application or in batch file?

Jx_Man 987 Nearly a Senior Poster Featured Poster

why did you use this and you use the call in the formload

I give you this code to make you more easier when you set a listview header. You can use this procedure at any event. Call used to call subroutine like procedure or function.

can you please put some comments sir so that i can understand what is the purpose for this.

Okay, I'll try to explain it.

Private Sub ColumnName(LSV As ListView, ParamArray lstview()) ' LSV declared as listview , lstview is an array to receive column name n width (see the paramaters when this procedure called in form load)
    Dim i, width
    LSV.View = lvwReport 'this will make listview looks like report view.
    width = LSV.width - 80 ' set the width
    With LSV.ColumnHeaders
        .Clear ' Clear the listview header before add headers.
        For i = 0 To UBound(lstview) - 1 Step 2 ' UBound used to get last index of an  array, step 2 is forward 2 steps (i=0,i=2,i=4,i=6...)
        .Add , , lstview(i), (lstview(i + 1) * width) / 100 ' lstview(i) is data on array at index i. lstview(i + 1) is data on array at index i + 1.
        ' Why is i + 1? cause in this looping we use step 2, so if index i is header name then index (i + 1) is header width.
        ' i=0 is header name, i=1 is header width, i=2 is header name, i=3 is header width, and so on.
        ' Call ColumnName(lvwStud, "First …
Jx_Man 987 Nearly a Senior Poster Featured Poster

If you have array textboxes then you can use looping to clear text box :

Dim i as Integer
For i = 0 to 10
    txt(i).Text = ""
Next

Or you can check if the type of control is text box then clear the control text.

For Each txt In Form1.Controls
    If TypeOf txt Is TextBox Then txt.Text = ""
Next
Sturdy commented: Really Great :) +1
debasisdas commented: agree +12
november_pooh commented: Helping +3
Jx_Man 987 Nearly a Senior Poster Featured Poster

Try This :

Option Explicit

Private Sub Form_Load()
 ConnectToDB
 Call ColumnName(lvwStud, "First Name", 40, "Last Name", 40, "Address", 70)
End Sub

Private Sub ColumnName(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this helps :

Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hwnd As Long, ByVal pszRootPath As String, ByVal dwFlags As Long) As Long
Dim RetVal As Long
Private Sub Command1_Click()
Dim y As Integer
   y = MsgBox("Are u sure to delete all items on Recycle Bin ? ", vbYesNo, "Confirmation")
   If y = vbYes Then
      RetVal = SHEmptyRecycleBin(0&, vbNullString, &H1)
   MsgBox "Recycle Bin has been cleaned"
   End If
End Sub
Naruse commented: Its Worked :) +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

you can use API file to do this.

Jx_Man 987 Nearly a Senior Poster Featured Poster

If done then please mark this thread as solved.

Thanks.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Private Sub Timer1_Timer()
TCount = TCount - 1

Label1.Caption = TCount  
If TCount = 0 Then
  Msgbox "Time's UP!"
End If
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster
ITKnight commented: Complete Guide +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

MySQL. its free to use.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Your're Welcome..
Please Mark your thread as solved..
you can find the link below the posts.

Jx_Man 987 Nearly a Senior Poster Featured Poster

Try this :

Set Picture1.Picture = Nothing

Don't forget to mark this thread as solved :)

Jx_Man 987 Nearly a Senior Poster Featured Poster

See this attachment.

Jx_Man 987 Nearly a Senior Poster Featured Poster

There are many way to accomplish this.
See if this help :

' Get a free file number
nFileNum = FreeFile

' Open a text file for input. inputbox returns the path to read the file
Open "D:\test.txt" For Input As nFileNum
lLineCount = 1
' Read the contents of the file
Do While Not EOF(nFileNum)
   Line Input #nFileNum, sNextLine
   'do something with it
   'add line numbers to it, in this case!
   sNextLine = sNextLine & vbCrLf
   sText = sText & sNextLine

Loop
Text1.Text = sText
' Close the file
Close nFileNum
november_pooh commented: Really Quick Solution.. thx jx +3
Vega_Knight commented: This a good stuf :) +2
Jx_Man 987 Nearly a Senior Poster Featured Poster

try it and let see how it works..

Jx_Man 987 Nearly a Senior Poster Featured Poster

See if this help.
This following example code is how to save image path into mysql:

Button Browse used to select an image and show the path to lblPath.

Private Sub btnBrowse_Click()
CommonDialog1.Filter = "All files (*.*)|*.*"
CommonDialog1.DialogTitle = "Select File"
CommonDialog1.ShowOpen

lblPath.Caption = CommonDialog1.FileName ' label path to show path of image
End Sub

Button Save used to store data into database.

Private Sub btnSave_Click()
With Adodc1
    .Refresh
    .Recordset.AddNew
    .Recordset.Fields("IdAddress") = txtIdAddress.Text
    .Recordset.Fields("First_Name") = txtFirstName.Text
    .Recordset.Fields("Last_Name") = txtLastName.Text
    .Recordset.Fields("Phone_Num") = txtPhoneNumber.Text
    .Recordset.Fields("Email") = txtEmail.Text
    .Recordset.Fields("PhotoPath") = lblPath.Caption ' This field will save path of selected image from common dialog.
    .Recordset.Update
End With
    MsgBox "Data Added"
End Sub
Jx_Man 987 Nearly a Senior Poster Featured Poster

Add reference : Microsoft CDO For Windows 2000 Library
5 textboxes, 1 button
Try This :

Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
    Dim oConfig As New CDO.Configuration
    Dim oMsg As New CDO.Message
    
    Label1.Caption = ""
    
    With oConfig.Fields
       .Item(cdoSendUsingMethod) = cdoSendUsingPort
       .Item(cdoSMTPServerPort) = 465
       .Item(cdoSMTPServer) = "smtp.mail.yahoo.com"
       .Item(cdoSMTPAuthenticate) = cdoBasic
       .Item(cdoSendUserName) = txtSender.Text
       .Item(cdoSendPassword) = txtPassword.Text
       .Item(cdoSendEmailAddress) = txtSender.Text
       .Item(cdoSMTPUseSSL) = 1
       .Update
    End With
    
    With oMsg
       .Configuration = oConfig
       .Subject = txtSubject.Text
       .To = txtAddress.Text
       .From = txtSender.Text
       .HTMLBody = txtMessage.Text
       .Send
    End With
    
    Set oMsg = Nothing
    Set oConfig = Nothing
    
    Label1.Caption = "Email Sent"
    Exit Sub

ErrHandler:

    MsgBox Err.Description, vbCritical, "Error"

End Sub