I'm a VB Newbie
Windows 2000
Ver 7.2.031
All I want this to do is trim my string. It returns the Value but doesn't want to trim the string.
Let>name= Ron
VBSTART
Function Trimstr(name)
Trimstr = Trim("%name%")
End Function
VBEND
VBEval>Trimstr(name),answer
MessageModal>%answer%
Simple Visual Basic function am I missing something?
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Hello Mundekis....
Try this script.
I added a few more spaces at front and end of name and modified the message to make the result more visible.
Try this script.
I added a few more spaces at front and end of name and modified the message to make the result more visible.
Since Trim is already a VB function you do not need to redefine it. Just run the VBSTART/VBEND at the beginning of the script. Then use VBEVAL with the normal VB syntax.
VBSTART
VBEND
Let>name= Ron
VBEval>Trim("%name%"),answer
MessageModal>Original Start.....%name%.....Stop%CRLF%%CRLF%has been modified to:%CRLF%%CRLF%Start.....%answer%.....Stop
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Thanks Bob
I'm now on my way to mastering VBScript. That takes care of lots of questions I've had.
VBEval and Trim
I have cust and pasted the code from Bob Hansen's sample and it does not work for me.
The return value is an empty string.
Any ideas?
The return value is an empty string.
Any ideas?
Let>name= Ron
VBEval>Trim("%name%"),answer
MessageModal>Original Start.....%name%.....Stop%CRLF%%CRLF%has been modified to:%CRLF%%CRLF%Start.....%answer%.....Stop
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Marcus,
please create a sticky note
Subject: How to copy and paste code from the forum.
Message body: Be sure when you Cut/Paste ...
Thx.
-----
Bob,
Run it with its assigned program and press F3 to fire your C&P comment as often as you like.
btw: why not using the cmd/command comment as a second hotkey in the same script ?
please create a sticky note
Subject: How to copy and paste code from the forum.
Message body: Be sure when you Cut/Paste ...
Thx.
-----
Bob,
FileExtension: ahkF3:: TrailingSpaces = Be sure when you Cut/Paste from the forum that you remove all trailing space characters. You can do this from the Macro Scheduler Editor. Click on Edit, Show All Chars and Remove Trailing Spaces.
ControlSend, %TrailingSpaces%
Return
Run it with its assigned program and press F3 to fire your C&P comment as often as you like.
btw: why not using the cmd/command comment as a second hotkey in the same script ?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The latest version of Macro Scheduler automatically removes trailing spaces and control chars from pasted code that has been copied from an HTML source (such as from Internet Explorer). So it really shouldn't be necessary to do this manually. In any case there is the Edit/Remove Trailing Spaces option that does it in one go.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Good suggestion Lumumba, maybe for someone else, but I rarely make hot keys.
And I don't have the problem, usually. You and I and other long time users are familiar with this. I usually include the caution in a forum message when I see a new user on the forum with some unknown problem, or try to prevent them from having the problem if I think they might be doing Cut/Paste from something I have submitted.
No big deal to clear them from the Edit menu when I have them. The big problem is knowing that you may need to do it, and do look for it. And as Marcus mentioned, the latest version corrects that, and now that I think about it, I honestly don't know that last time I actually had to do that myself.
Re a "sticky", that may be redundant. The following information is "whispered" just above the box I am typing into now:
=====================
With all that said, I wonder if that caused/corrected the problem that was originally brought up a few messages ago?
And I don't have the problem, usually. You and I and other long time users are familiar with this. I usually include the caution in a forum message when I see a new user on the forum with some unknown problem, or try to prevent them from having the problem if I think they might be doing Cut/Paste from something I have submitted.
No big deal to clear them from the Edit menu when I have them. The big problem is knowing that you may need to do it, and do look for it. And as Marcus mentioned, the latest version corrects that, and now that I think about it, I honestly don't know that last time I actually had to do that myself.
Re a "sticky", that may be redundant. The following information is "whispered" just above the box I am typing into now:
That was pointed out to me many years ago when I was complaining about Cut/Paste. I was told that by using "Code" the problem would not occur. But I can't be bothered to use Code in addition to Quote and prefer the appearance that I see with Quote tools.If pasting script code, highlight it and press the 'Code' button to ensure it can be copied and pasted correctly
=====================
With all that said, I wonder if that caused/corrected the problem that was originally brought up a few messages ago?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!