Results 1 to 12 of 12

Thread: command textbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    command textbox

    Hello again,

    Going by my last thread, I also in my system have an actions textbox. Is it possible and how is it possible for when I type in a certain word then follow that word with a / and then what ever I type in after, it places that in a certain textbox and listview else where on the system. Its very difficult to explain but we use it at work so I know its possible aha

    Example: if I wanted to add a time in a textbox which is set to readonly by using a command of one of the items in a textbox (read my previous listbox/textbox thread for reference) then i would put "TP/OP28".
    TP = time present and OP28 is one of the items i have in a textbox (if i can have items in a textbox, again, see the last thread) then that would place the time it is now in a certain textbox and listview row. However if the item i typed after the / isn't in the textbox then i have an error message saying the item isn't in the textbox etc.

    It doesn't have to be just TP i would like other functions as well but the first letters before the / are the commands that tell the system what sort of command it has to do once i type what ever it is after the / and then press enter

    Or another one would be like: AR/'free text' and then enter. I want this so when the user enters AR that means authorization reason the / is a spacer and the text after / is what's placed in the AR box ( your probably thinking can't you just place the cursor in the AR textboz and write the reason, the design and functionality of my system.doesnt allow that and it needs to be done this specific way.

    Hope you can understand this and can help me!!

    Thanks ever so much!!

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: command textbox

    Like this ... ?

    vb.net Code:
    1. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    2.         Action(TextBox1.Text)
    3.     End Sub
    4.  
    5.     Private Sub Action(ByVal command As String)
    6.         Dim Actions = command.Split("/"c)
    7.         Select Case Actions(0)
    8.             Case "TP"
    9.                 ' do something with Actions(1)
    10.             Case "AR"
    11.                 ' do something different with Actions(1)
    12.  
    13.                 ' etc.
    14.         End Select
    15.     End Sub
    16. End Class
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: command textbox

    I would go with dunfiddlins but put it in the textbox kepress (or keydown) event handler and run the code if the <Enter> key was press and if TextBox1.Text.Contains("/")
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    Cheers for the coding, I shall test it in the morning!

    Where it says 'do something with actions(1) is that where I put the code for the text used after / ? of so what sort of code is it? Sorry fir the hassel! Haha

    Its basically the first letters before the / is determines where the text after the goes, ie: AR/testing and enter will then place testing in the AR textbox which could be textbox 21 or 36 etc etc, just to confirm?

    Cheers

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    Cheers for the coding, I shall test it in the morning!

    Where it says 'do something with actions(1) is that where I put the code for the text used after / ? of so what sort of code is it? Sorry fir the hassel! Haha

    Its basically the first letters before the / is determines where the text after the goes, ie: AR/testing and enter will then place the word testing in the AR textbox which could be textbox 21 or 36 as it was after the / the text before the / just tells where the text after / goes etc, just to confirm?

    Cheers

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: command textbox

    It takes the line eg. TP/OP28 and splits it using / as the delimiter to give you two strings; Actions(0) = "TP", Actions(1) = "OP28"
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    Ah right I see.

    So what would I put for the actions 1 part? Ie. How to make it detect what I've out after the / ?

    Cheers

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    Hi, Ive tried the coding you supplied and it works well except i dont think its detecting the words im typing after the "/" as when i type in "TP/" in the actions box the time does come up but i need it to be something like "TP/OP28" or what other words are in the other textbox (refer to my other thread)

    Thanks

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: command textbox

    Quote Originally Posted by Sean.Downes View Post
    Hi, Ive tried the coding you supplied and it works well except i dont think its detecting the words im typing after the "/" as when i type in "TP/" in the actions box the time does come up but i need it to be something like "TP/OP28" or what other words are in the other textbox (refer to my other thread)

    Thanks
    If you're using dunfiddlin's code then it IS detecting it but it's not using it. As dunfiddlin's code points out, you are supposed to use the the part that comes after the slash inside each case. Maybe you should show us the actual code you're using because plenty of people claim to be doing something that isn't working and when we see what they're actually doing it is not what they claimed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    Sorry, just reading my last post, it doesnt actually make sense, must be to early still!

    The code works great it does put the time in the TP field but on another field theres a textbox called assigned when i type in a word like OP28 then press enter i want to add 2 spaces after that word and then place that word in a listview, so far that works as well but instead of putting in just the one word i had just typed it puts the whole textbox in the listview item which isnt what i want (see my other thread).

    So when the user puts the command in the actions box "TP/**" (the ** bit is where one of the words from the textbox assigned field should be, if its not in the assigned field then a time cant be placed in the TP field until after the "/" a word that is also in the Assigned field is placed) and then presses enter i want it to show the time now in the TP field and then update the listview item with the word after the "/" I.E. "OP28" to update that listview item and put in the time now on that call sign item.

    Does that make better sense?

    Cheers
    Last edited by Sean.Downes; Apr 26th, 2013 at 03:30 AM.

  11. #11
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: command textbox

    It makes sense of why I said it didn't make sense to keep extending the line in the OP textbox! With a line such as ...

    OP28 OP29 OP30

    ... which exactly is meant to be the current value? Is it always the last one typed? Do you want to be able to select a value?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    171

    Re: command textbox

    The textbox with OP28 etc are call signs for units for engineers etc. it could be any number or any letter, not always OP28 OP29 etc.

    when i type in TP/'then one of the units assigned (the unit after the / has to also be entered in the assigned field) will it then place a time in a time present field, that make any sense, so the first letter before the / is just so the computer knows where to add the data after the / this instance it will be the time present, there are other action codes as well but im not going to implement those until this one is done so i can refer to it, like i said earlier your code does work but it only works when i type in TP/ then a time is placed, i want it so you type i TP/'then the unit call sign and then press enter.

    Cheers

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