|
-
Sep 1st, 2000, 11:51 PM
#1
Thread Starter
Hyperactive Member
This may seem like a really easy question for some of you, but I can't seem to get this...
I have a RichTextBox on my form and I want to save the text I write in it in a .ini file in a particular directory. I got it working with a normal text box, but for some reason it doesn't work for richtextboxes... I got this code from a site:
-------------------------
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Const INIFileName = "C:\MyFile.ini"
------------------------------------
Private Sub Command1_Click()
'The following code line will save the text in Text1 under the section 'My App Name'
'and Under the Key 'My Key'.
Result = WritePrivateProfileString("My App Name", "My Key", Text1.Text, INIFileName)
End Sub
Private Sub Command2_Click()
Dim MyValue As String * 20
'The following code line will get the value of the key 'My Key' under the;section 'My App Name', and will insert the vale to the variable 'MyValue'.
Result = GetPrivateProfileString("My App Name", "My Key", "Empty", MyValue, Len(MyValue), INIFileName)
Text1 = MyValue
End Sub
=======================
This is the original code I got from the site, I just changed where it says "text1" to "Richtextbox1" and that all the changes I did to it...
Can anyone tell me what am I doing wrong or can you just show me a simpler way of doing this whole thing, for example using .txt instead of .ini?
Thanks!
-Emo
-=VB6 Enterprise Edition=-
-=VC++6Enterprise Edition=-
«¤E³m°O²™¤»
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
|