|
-
Jun 6th, 2001, 06:52 PM
#1
Thread Starter
Fanatic Member
Left$
Hi Everyone,
Is there any such thing as a left$. I want to capture the first 3 letters of a name but I cannot get the VB program to recognize the Left$ procedure. For example, I want this.
Name = Inventory
Code:
strFile = Left$(" & Text1.Text & ", 3)
New Name = Inv
-
Jun 6th, 2001, 06:54 PM
#2
???
VB Code:
strFile = Left$(Text1.Text, 3)
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 6th, 2001, 06:58 PM
#3
Addicted Member
Try this:
Dim strFile as String
strFile = Left(" " & Text1.Text & " ", 3)
-
Jun 6th, 2001, 06:59 PM
#4
_______
<?>
If you are lazy like me you can save 3 key presses
strFile = Left$(Text1, 3)
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 6th, 2001, 06:59 PM
#5
BTW...
The reason Left$ does not come up with Intellisense is because it sees Left as the Left property for your form. Try it in a module and it works
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 6th, 2001, 07:04 PM
#6
Thread Starter
Fanatic Member
Thanks for your reply crptcblade. It still doesn't recognize it though. When I type Left$ and hit the "(" sign, nothing even recognizes that it is doing a left string function. When I try a Right$( I receive a tooltip that says Right$(String As String, Length As Long) As String. Any ideas what may be wrong?
-
Jun 6th, 2001, 07:05 PM
#7
funny, not even in a bas module? Hmmm...It works for me
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 6th, 2001, 07:07 PM
#8
_______
<?>
Works for me..
Code:
Private Sub Command1_Click()
MsgBox Left$(Text1, 3)
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 6th, 2001, 07:08 PM
#9
You can also use the Mid function.
VB Code:
strFile = Mid$(Text1.Text, 1, 3)
MsgBox strFile
-
Jun 6th, 2001, 07:29 PM
#10
Addicted Member
One thing that brings an element of confusion to me, not speaking
for others, is this:
VB can create variables on the fly. This is not necessarily a good thing. In real practice, I believe in declaring all variables, i.e., Dim strFile as String.
Afterwords, call the "Left" function as I've illustrated above. It
should work OK.
Redundancy is exposed in the code: strFile = Left$(whatever, how many)
Declare the variable and call the function as intended:
Dim MyString as String
MyString = Left(SomeString, NumberOfPlacesFromTheLeft)
-
Jun 6th, 2001, 08:03 PM
#11
Actually, I've noticed this before too. While the Left() function works, it does not display the arguments in a tooltip, whereas the Right and Mid functions do. {VB6 SP5}
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jun 6th, 2001, 08:11 PM
#12
Originally posted by crptcblade
BTW...
The reason Left$ does not come up with Intellisense is because it sees Left as the Left property for your form. Try it in a module and it works
here's the reason. You can reference properties/methods of a form without using the form name while your are in that form's code module. Like :
VB Code:
'in a form module
Left = Top - 20
is the same as :
VB Code:
'in a form module
Me.Left = Me.Top - 20
again, use the Left() function in a bas module and you'll see the tooltip
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 6th, 2001, 11:29 PM
#13
Thread Starter
Fanatic Member
Hi Everyone,
Thanks for your advice. I can get the Left$ function to work inside of the bas module and inside of the MsgBox ok, but this is what I am really trying to do. I have inserted the ImgScan.ocx control on my form and have developed some scanner code to work with it. I am trying to save the image as a bitmap file to the following location. I want to save the file with the first 3 letters of the name in Text2.Text plus have the current date at the end. For example, if the name in Text2.Text was INVENTORY. The file would be saved as INV6/6/01.bmp. Make sense? I can get the Left$ function to work ok but I receive a bad file name error when I try to add the date on the end. Any ideas what I am doing wrong? I would appreciate any help. Thank you.
Code:
"C:\Scanner Test\Folder1\" & Left$(Text2.Text, 3) & Date & ""
-
Jun 6th, 2001, 11:50 PM
#14
Originally posted by Ace
Code:
"C:\Scanner Test\Folder1\" & Left$(Text2.Text, 3) & Date & ""
Just lettin' you know, you don't need the last three characters .
Code:
"C:\Scanner Test\Folder1\" & Left$(Text2.Text, 3) & Date
-
Jun 6th, 2001, 11:51 PM
#15
I know exactly what is wrong. You cannot have a filename with these characters in it : \ / : * ? > < " |
try using Replace() to switch the "/" with a valid character.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|