|
-
Nov 9th, 2000, 07:42 PM
#1
Thread Starter
Fanatic Member
If I wanted to extract all of the characters in a text box prior to the first space what would be the coding?
-
Nov 9th, 2000, 07:54 PM
#2
0 to 32 are not characters.
Set TextBox's multiline property to True.
Code:
For i = 33 to 255
Text1.text = Text1.text & Chr(i) & vbCrLf
Next i
If you intend to state from 0 to 32, you will recieve either spaces or squares.
-
Nov 9th, 2000, 07:59 PM
#3
Thread Starter
Fanatic Member
I am not following. What I am doing is trying to extract some numbers from a text box. The way I have it setup right now is that in this text box on the get focus method it grabs the date created attribute from a file on the network. I would like to trim the time off at the end (because in the created attribute it will show something like this: 11/8/2000 1:03:06 PM). I want to just get 11/8/2000..
-
Nov 9th, 2000, 08:04 PM
#4
Frenzied Member
put a text box and a command button on a form and run this code:
Code:
Option Explicit
Private Sub Command1_Click()
MsgBox GetLeftOfSpace(Text1)
End Sub
Private Function GetLeftOfSpace(asText As String) As String
GetLeftOfSpace = Left$(asText, InStr(1, asText, " ") - 1)
End Function
Type something into the textbox (with a space...) and click the button. It will only display the text from the textbox to the left of the space in a message box.
[Edited by seaweed on 11-09-2000 at 08:11 PM]
-
Nov 9th, 2000, 08:06 PM
#5
Why didn't you say so? 
I didn't understand you the first time.
Now we're getting somewhere.
11/8/2000 1:03:06 PM
11/8/2000
Use the Left function.
Left(Text1.text, 9) 'returns 11/8/2000
Or you can use the Mid function.
Mid(Text1.text, 1, 9) 'returns 11/8/2000
-
Nov 9th, 2000, 08:14 PM
#6
Thread Starter
Fanatic Member
It works great one more question.
Why would some computers read the date as 11/9/2000 and others as 11/9/00? These are all Windows machines.
-
Nov 9th, 2000, 08:15 PM
#7
Frenzied Member
Another solution
Just format the output like this:
Code:
Text1 = Format(Text1, "mm/dd/yyyy")
That will format whatever is in your text box to display just the month, day, and year. The time should be hidden.
I think this will work for you.
-
Nov 9th, 2000, 08:18 PM
#8
Thread Starter
Fanatic Member
-
Nov 9th, 2000, 08:19 PM
#9
Frenzied Member
Depends on the machines date settings. Again, the format function can change the way it's displayed.
Code:
Format(Now, "mm/dd/yy") ' displays: 11/09/00
Format(Now, "mm/dd/yyyy") ' displays: 11/09/2000
Format(Now, "dddd, mmmm dd, yyyy") ' displays: Thursday, November 09, 2000
[Edited by seaweed on 11-09-2000 at 08:23 PM]
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
|