|
-
Mar 28th, 2007, 12:38 PM
#1
Thread Starter
Lively Member
reset command
how to write the code to clear the content inside text box when the button is press.
-
Mar 28th, 2007, 12:39 PM
#2
Re: reset command
Code:
Private Sub Command1_Click()
Text1.Text = vbNullString
End Sub
-
Mar 28th, 2007, 04:02 PM
#3
Re: reset command
Properly:
Code:
Private Sub Command1_Click()
Text1.Text = ""
End Sub
Although Hack's code works, vbNullString is not the same as a zero-length string. That's directly from MSDN, which also states that vbNullString is used for calling external processes.
-
Mar 28th, 2007, 04:48 PM
#4
Re: reset command
have a look at this, I thought it was kind of interesting
Code:
Private Sub form_Click()
Dim S As String
Debug.Print vbNewLine & "StrPtr with a VB string"
S = " ": Debug.Print """ "" ="; StrPtr(S)
S = "": Debug.Print """"" ="; StrPtr(S)
S = vbNullChar: Debug.Print "vbNullChar ="; StrPtr(S)
S = vbNullString: Debug.Print "vbNullString ="; StrPtr(S)
Debug.Print vbNewLine & "Now StrPtr for a textbox"
Text1.Text = " ": Debug.Print """ "" ="; StrPtr(Text1.Text)
Text1.Text = "": Debug.Print """"" ="; StrPtr(Text1.Text)
Text1.Text = vbNullChar: Debug.Print "vbNullChar ="; StrPtr(Text1.Text)
Text1.Text = vbNullString: Debug.Print "vbNullString ="; StrPtr(Text1.Text)
End Sub
With a VB string the only way to clear the BSTR is with vbNullstring, but the Text property also clears the BSTR with "" and vbnullchar. By clear I mean makes the string variable point to a null structure.
Last edited by Milk; Mar 28th, 2007 at 06:03 PM.
Reason: Added link to an article discussing VB strings and their BSTR structure
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
|