Results 1 to 6 of 6

Thread: [RESOLVED] How To Combine String From DTPicker and Textbox?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Resolved [RESOLVED] How To Combine String From DTPicker and Textbox?

    I need to combine date from a DTPicker, and numbers from a textbox (lets say text1). How do i do this? I tried text2= DTPicker + Text1, but Vb6 add text1 to DTPicker mathematically instead of combining the string. Sorry if this is too basic. Thanks in advance

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How To Combine String From DTPicker and Textbox?

    Use & not + when concatenating strings. Does that help?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Re: How To Combine String From DTPicker and Textbox?

    Quote Originally Posted by LaVolpe View Post
    Use & not + when concatenating strings. Does that help?
    I will try it

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Re: How To Combine String From DTPicker and Textbox?

    Quote Originally Posted by LaVolpe View Post
    Use & not + when concatenating strings. Does that help?
    i tried it, and it works. thanks a lot

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Re: [RESOLVED] How To Combine String From DTPicker and Textbox?

    Quote Originally Posted by LaVolpe View Post
    Use & not + when concatenating strings. Does that help?
    Hey man, I got another problem.

    The date in dtpicker's date wont save (insert) to a database field that i designed for it. So when i clicked save, the "tglabsen" field is empty. I am using MySql, and i set tglabsen's type as DATE. Is it has anything to do as to why the date generated by DTPicker wont saved to it? I changed the fields type in mysql into varchar, and it works. The format of the date is separated by "/" (like 07/07/2017). Is it has anything to do with the date format?

    Also, the combining string method works fine. I combined the primary key for the employee, which is 011, to the date from DTPicker. I got 07/07/2017011, and its stored in a textbox. But when I tried to save it to the mysql table, the program only stores the date part, and not the primary key. How can this happen?

    Here is the code that i use :

    Sub simpanbrg()
    simpan = "insert into absen (kd_absen, NIP, tglabsen) values('" & tkode & "', '" & cnip.Text & "', '" & dtpicker & "')"
    KON.Execute simpan
    End sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2015
    Posts
    103

    Re: How To Combine String From DTPicker and Textbox?

    Quote Originally Posted by LaVolpe View Post
    Use & not + when concatenating strings. Does that help?

    Hey man, I got another problem.

    The date in dtpicker's date wont save (insert) to a database field that i designed for it. So when i clicked save, the "tglabsen" field is empty. I am using MySql, and i set tglabsen's type as DATE. Is it has anything to do as to why the date generated by DTPicker wont saved to it? I changed the fields type in mysql into varchar, and it works. The format of the date is separated by "/" (like 07/07/2017). Is it has anything to do with the date format?

    Also, the combining string method works fine. I combined the primary key for the employee, which is 011, to the date from DTPicker. I got 07/07/2017011, and its stored in a textbox. But when I tried to save it to the mysql table, the program only stores the date part, and not the primary key. How can this happen?

    Here is the code that i use :

    Sub simpanbrg()
    simpan = "insert into absen (kd_absen, NIP, tglabsen) values('" & tkode & "', '" & cnip.Text & "', '" & dtpicker & "')"
    KON.Execute simpan
    End sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width