| | |
Help needed please VB5
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Solved Threads: 0
Hello, I wish to create a document in a word processor with all the formating etc and save it, then I wish to drop this document on to my form in some control or object so it is hidden from the end user then I wish to load the hidden document into a rich text box so that the end user can read the text of the hidden document, I don't wish to load this document into my project using the open dialog control every time the user opens my project or use any load or shell commands, how can I accomplish this task please ?
Cheers MagicBytes
Cheers MagicBytes
In the first place, there's no need to drop a document onto your project, form, or whatever. All you need to know is where the location of the file is.
And then you need to establish some process with a command button, a click event (on a form), etc. to call up the desired document.
You're shooting yourself in the foot.
It is not possible to not load something into memory that you want to load into memory that you want to use. A shell command is the easiest and quickest solution. You could use an API from the SDK. But that would be more difficult.
What are you trying to accomplish, hide yourself from a user who is running a program that blows up the world if it detects a load a shell request from Visual Basic?
And then you need to establish some process with a command button, a click event (on a form), etc. to call up the desired document.
You're shooting yourself in the foot.
•
•
•
•
I don't wish to load this document into my project using the open dialog control every time the user opens my project or use any load or shell commands
What are you trying to accomplish, hide yourself from a user who is running a program that blows up the world if it detects a load a shell request from Visual Basic?
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Solved Threads: 0
Hello and thanks for the reply.
Well here is my problem with the shell command, example below
RichTextBox1.FileName = ("C:\Documents and Settings\UserName\My Documents\MyDocumentFile.rtf")
Now as you well know, every bodies computer has different User Account Names, so how am I suppose to get around this problem ?
For instance I could use some thing like this below...
RichTextBox1.FileName = ("C:\Documents and Settings\" & UserName & "\My Documents\MyDocumentFile.rtf")
This would suit my project better if I knew how to accomplish this task in VB5, because then it wouldn't matter what an end users computer account name is. my project would always find the rich text file in the documents folder on any ones machine.
I hope I explained why I would like to imbed my document file into the form of my project, this way at least the end user can place my projects excutable in any folder on any drive they choose and my project would always come with my doccument file and would not generate any error messages like "FILE NOT FOUND ! ! !" etc.
Plus using an open dialog control would annoy any user if they had to continually look for and load in my document file every time they wanted to run my project, that would be simular to a NAG screen that every one hates when they are testing out shareware or trialware etc.
I am trying to keep my project as USER FRIENDLY as possible to the END USER.
I need to use this document file in my project because it explains useage etc about my project, I have provided a lengthy file explaining many things and it has been different colored text styles and all the font formatting too etc etc etc...
So I hope you have a better understanding to the nature of my project and any ideas and comments will be very helpful.
So if there is a VB5 command that looks up a users account name this would be very helpful also.
Thanks in advance ...
Cheers from MagicBytes
Well here is my problem with the shell command, example below
RichTextBox1.FileName = ("C:\Documents and Settings\UserName\My Documents\MyDocumentFile.rtf")
Now as you well know, every bodies computer has different User Account Names, so how am I suppose to get around this problem ?
For instance I could use some thing like this below...
RichTextBox1.FileName = ("C:\Documents and Settings\" & UserName & "\My Documents\MyDocumentFile.rtf")
This would suit my project better if I knew how to accomplish this task in VB5, because then it wouldn't matter what an end users computer account name is. my project would always find the rich text file in the documents folder on any ones machine.
I hope I explained why I would like to imbed my document file into the form of my project, this way at least the end user can place my projects excutable in any folder on any drive they choose and my project would always come with my doccument file and would not generate any error messages like "FILE NOT FOUND ! ! !" etc.
Plus using an open dialog control would annoy any user if they had to continually look for and load in my document file every time they wanted to run my project, that would be simular to a NAG screen that every one hates when they are testing out shareware or trialware etc.
I am trying to keep my project as USER FRIENDLY as possible to the END USER.
I need to use this document file in my project because it explains useage etc about my project, I have provided a lengthy file explaining many things and it has been different colored text styles and all the font formatting too etc etc etc...
So I hope you have a better understanding to the nature of my project and any ideas and comments will be very helpful.
So if there is a VB5 command that looks up a users account name this would be very helpful also.
Thanks in advance ...
Cheers from MagicBytes
•
•
•
•
Now as you well know, every bodies computer has different User Account Names, so how am I suppose to get around this problem ?
' Declaration Section
Public Declare Function GetEnvironmentVariable Lib "Kernel32" _
Alias "GetEnvironmentVariableA" (ByVal lpName As String, _
ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub cmdFetchEnv_Click()
On Error GoTo Fetch_ERROR
Dim lngReturn As Long
Dim strVar As String
Dim strBuffer As String * 255 ' Be careful to declare this as written, otherwise you'll get
' a runtime error that you will not be able to recover from.
Dim strMiddle As String
Dim intPos As Integer
' The lngReturn value should give the length of the Environment Variable
' the txtEnvir variable should filled in with "USERPROFILE" for your purpose
' but can be replaced with any Environment Variable: TEMP, OS, PATH, etc.
lngReturn = GetEnvironmentVariable(txtEnvir, strBuffer, 255)
If lngReturn = 0 Then ' An error occured, process it.
GoTo Fetch_ERROR ' Oh, my soul. A dreaded GOTO statement
End If
' Use the left function to cut off the unwanted null characters
strVar = Left(strBuffer, lngReturn)
' You need to cut out the "\" characters to find the actual user name
intPos = 1
While intPos <> 0
intPos = InStr(1, strVar, "\", vbTextCompare)
strVar = Right(strVar, Len(strVar) - intPos)
intPos = InStr(1, strVar, "\", vbTextCompare)
Wend
' This should be your answer as to the username
txtEnvResult = strVar
Exit Sub
Fetch_ERROR:
Dim LastError As Long
LastError = Err.LastDllError
MsgBox "You had an error: Error: #" & CStr(LastError), vbInformation, "Error"
End Sub![]() |
Similar Threads
- To Degree or not to Degree - that is my question (IT Professionals' Lounge)
- URL on Windows clipboard to a image control - help needed please (Visual Basic 4 / 5 / 6)
- ASP,VB, SQL Team Lead needed now (Web Development Job Offers)
- Database Deployment In VB Applications (Visual Basic 4 / 5 / 6)
- Multiple images to a single bmp/jpg image (Visual Basic 4 / 5 / 6)
- audio level detection (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Rich Text Box
- Next Thread: problem with quotes in SQL statement
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





