hey thanks, its working, thats really good i did alot of coding to get that path ,i also tried Environment.GetCommandLineArgs() but i didnt knew what is this and how to use it?
to open text files i always use rich textbox because it have more functions than textbox
i didnt understand that how the value\file path come in this variable(filepath)...????
Private Sub LoadFile(ByVal <code>filepath</code> As String)
buddy i have another question thst is
when i click on a button then it should change open with program to mine application
I'm just adding (another) final piece to my app which involves printing. Okay, not much fun but, been there before and bought the T-shirt.
Okay, it seems to work, I'm printing exactly what I expect to see on an HP LaserJet.
I've got a PrintDialog component to allow me to select the printer. I select a second printer, Epson,(rather than the default HP) and all I get is a pile of blank pages. Have to cancel the document, turn off the printer and wait 5 minutes.
If I swap the default printer to the Epson, same thing happens on that printer but I can use the PrintDialog to select the HP which as before, works fine. So the PrintDialog appears to be working.
Stepping through the PrintDocument method, the strings being "printed" appear to contain the correct data - in short, the method looks to be doing exactly what it should (as it must, as I can print on the HP).
Print preview works fine whichever printer is selected.
When the Epson is reset, I can print a test page okay from Word.
So, to summarise:
1) The Epson printer works
2) The PrintDocument1.Print method works
3) The Printdialog works
4) The Print preview works.
So why can't I print on the damn Epson?
Another part of my project which has been tested to death, allows the selection of a printer. Just tried a test print with this and got the same thing - endless blank pages on the Epson. The code here has not been changed and used to work fine.
First u decide which form's title must be show in task bar .
if u want to show same form title for all condition, then change the property ShowInTaskBar to false for all other remaining form.
and if u want to show different title for different form at the base of active form(but have only one window in task bar) then set ShowInTaskBar property to false for all other form at load event of present active form.
I have a VB MFC that uses a dll for sending, receiving, dispalying and logging data from/to another application the problem is that SOMETIMES when I close the VB window by clicking on X the application goes off ( you do not see it on desktop) but when you open the task manager, you can see that the application is still there. The problem is that it happens just sometimes. Any ideas?
It is the way I close the appliaction:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("Are you sure you want to Exit the application?", vbYesNo + vbQuestion, "Application") = vbNo Then
Cancel = True
Private Sub MDIForm_Terminate()
Private Sub MDIForm_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
The other question is that how I can check if an application is running and if for any reason (even a hard close by user) the application is closed, it reopens itself.
This is usually caused by an improper shutdown of a component in your app. Most likely, this would be the .DLL you're using. It's possible that it created a seperate thread(s) that are still running when your app quits. You'll have to check with the docs or anything else you can find on this library and see if it needs you to do anything special to shut it down before your app closes.
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
Yes! Any .DLL you load becomes a part of your code, not a seperate process. This is a curious question, because throughout all coding, if your code creates or loads something, your code is also responsible for managing and destroying that something properly.
Making the assumption that an object or runtime can clean itself up without you telling it to do so is a very bad thing to do. This practice leads to unstable applications and operating systems. For instance, if you application creates a Graphics object, you are also responsible for destroying it when your done with it. If not, you'll eventually run the system out of resources and crash the whole operating system.
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
Dim oOutlook As New Outlook.Application
Dim oMailitem As Outlook.MailItem
Dim oAttach As Outlook.Attachment
oMailitem = CType(oOutlook.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItem)
oMailitem.To = "Jack <email@example.com>"
oMailitem.Subject = "Your Subject "
oMailitem.Body = "Hello, "
Thankx a lot for your help!!!
The code is perfect...i did it before but missed a line
Can you please tell me how to add multiple lines in the body, One line after the other, should i use some thing like or \n.
Function MailComponent(ByVal mailTo As String, ByVal cc As String, ByVal Bcc As String, ByVal subject As String,byval bodyofMessage as string)
Dim str, body As String
str = ""
If bodyofMessage Is Nothing Then
body = bodyofMessage
If cc Is Nothing Then
cc = ""
If Bcc Is Nothing Then
Bcc = ""
If subject Is Nothing Then
subject = ""
'string builder used for concatination
Dim MsgBuilder As New System.Text.StringBuilder
MsgBuilder.Append("mailto:" & mailTo)
If Not cc.Trim = "" Then
MsgBuilder.Append("&cc=" & cc)
If Not Bcc.Trim = "" Then
MsgBuilder.Append("&bcc=" & Bcc)
If Not subject.Trim = "" Then
MsgBuilder.Append("&subject=" & subject)
If Not Body.Trim = "" Then
MsgBuilder.Append("&body=" & Body)
If Not Attachment.Trim = "" Then
MsgBuilder.Append("&Attach=" & Attachment)
Function ExecuteFile(ByVal FileName As String) As Boolean
Dim myProcess As New Process
myProcess.StartInfo.FileName = FileName
myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.RedirectStandardOutput = False
I need very urgent this requirement
i have tio implement in my project
I have implemented httpwebrequest through access the web pages
I want to login to home page using webrequest. it successfully logged into the site but it is unable to showing in web browser , it says session expired.
just see below example if have any solution give me reply
very urgent plz........................
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim query As String = "firstname.lastname@example.org&password=regards &commit=Login&loginType=emp"
Dim url2 As String = "sourceurl"
Dim url3 As String = "target / home page url"
Dim src As String = ""
src = readHtmlPage(url2, query, url3)
src = getpage(url3)
Public Function getpage(ByVal strurl As String) As String
Dim responseData As String = ""
Dim responseReader As StreamReader
webRequest1 = WebRequest.Create(strurl)
webRequest1.Timeout = 30000
webRequest1.Method = "GET"
responseReader = New StreamReader(webRequest1.GetResponse.GetResponseStream)
responseData = responseReader.ReadToEnd
Catch ex As Exception
MessageBox.Show(ex.Message.ToString, "vcv", MessageBoxButtons.OK, MessageBoxIcon.Error)
Function readHtmlPage(ByVal url As String, ByVal strpost As String, ByVal url1 As String) As String
Dim result As String = ""
Dim myWriter As StreamWriter
Dim objRequest As HttpWebRequest = WebRequest.Create(url)
objRequest.Method = "POST"
objRequest.ContentLength = strpost.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
objRequest.CookieContainer = New CookieContainer
myWriter = New StreamWriter(objRequest.GetRequestStream())
Catch e As Exception
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd()