|
Somehow a Windows application is closing when trying to dispose of the calling form using me.dispose.
If .. = True Then
Dim SelectFiles As New frmSelectClearingFiles
SelectFiles.Show()
Me.Dispose()
Else
..
Any ideas?
Jon
|
|
|
|
|
Please tell me this code isn't on your startup form!
If you close, or dispose, the startup form, you're entire application dies. The startup form has the applications message pump attached to it. If that goes away, so does your app.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 12:56 Tuesday 27th June, 2006
|
|
|
|
|
Yep, it's the startup form, thanks.
Jon
|
|
|
|
|
I'm in need of being able to create MS Word documents and edit them from VB 6.0. I know that this can be done via VB .NET and also C#; but I'm wondering if all of the calls the VB .NET and C# make to Word are also available in VB 6.0? Thanx!
-Kris
|
|
|
|
|
Yes.
All of the calls that VB.Net and C# can make via the Interop are also available in VB6.0 by referencing the MSWord.olb file in your project.
I suggest you get an MS Office Word Language Reference book to find out the object model and functions available.
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Yes all the calls are available
Check this
Dim MyPath as string = "c:\test\"
Set ObjWordKit = CreateObject("Word.Application")
With ObjWordKit
.Visible = True
.Documents.Add (MyPath & "yourtest.dot")
.activedocument.Bookmarks("MyText").Select
.Selection.Text = "set into word text"
end with
if you need other functions from Word, make a Word-macro and just copy the code and you are close.
Hope this helps
Jesper
|
|
|
|
|
I was wondering if anyone knows of a way to call a C# program from Visual Basic 6.0. I currently have a VB 6.0 application and I'd rather not have to go through the pain in upgrading it to VB .NET but I need to enhance it to call some C# code. Does anyone know if this is even possible in VB 6.0? Thanx!
-Kris
|
|
|
|
|
You can enable COM-Interop registration in the properties of the assembly. You can then use it like any other COM library.
|
|
|
|
|
Hi All - Need ur help
Hi, I am jats working as a s/w Developer. I need some help from u.
I am new to .net and using it from past 2 weeks. During my project i got a problem.
My project has a requirement of sending mail to some mail a/c, when user clicks on a submit button.
I wrote some code for it but i am getting a Inner Exception saying.....
"Failure sending mail.Unable to read data from the transport connection:An existing connection was forcibly closed by the remote host"
The code is as follows………
Private Sub SendMail()
Dim smtpClient As SmtpClient
Dim message As MailMessage
Dim fromAddress As MailAddress
smtpClient = New SmtpClient()
message = New MailMessage()
Try
fromAddress = New MailAddress("from@xxx.com")
smtpClient.Host = "Smtp Server string"
smtpClient.Port = 25
message.From = fromAddress
message.To.Add("to@xxx.com")
message.Subject = "Feedback"
message.Body = "This is Body Part"
smtpClient.Send(message) '*****Raising Exception here*****
MsgBox("Email successfully sent.")
Catch ex As Exception
MsgBox("Send Email Failed." + ex.Message + ex.InnerException.Message)
End Try
End Sub
Note: I am not using any mail server is it neccesary to do so. If it is plz specify me One mail server.
Plz send me some Document to relevent topic if u hav it. And ur suggesstion on this topic.
Waiting for a positive response…..
jats.
jats_4ru@yahoo.co.in
|
|
|
|
|
|
one question Visual Basic in Lounge!
whitesky
|
|
|
|
|
Sorry, this site is about soccer only. You should try to post your programming questions on the FIFA[^] website
|
|
|
|
|
|
Stlan wrote: Sorry, this site is about soccer only. You should try to post your programming questions on the FIFA[^] website
Actually he's proably done worse by posting it in the lounge.
FIFA would have been a little more considerate.
Abhishek
|
|
|
|
|
Mr.Gundala wrote: message.Body = "This is Body Part"
here you have your error!
it should be either:
message.Body = "This is the whole Body."
or
message.BodyPart = "This is a Limb."
|
|
|
|
|
Mr.Gundala wrote: Note: I am not using any mail server is it neccesary to do so.
Well, now that the Lounge Lizards are done smacking you around...
"smtpClient.Host = "Smtp Server string" " says you are using a mail server, if and only if "Smtp Server string" actually resolves to something useful, and yes, a mail server is required.
But, since you're getting a "An existing connection was forcibly closed by the remote host" error, it would appear that the SMTP server you're using doesn't like you for some reason and is hanging up on you. You might want to find out from whoever owns the server, why.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 10:58 Tuesday 27th June, 2006
|
|
|
|
|
Thanku very much. I will check the server...
jats
|
|
|
|
|
As Dave said above, and also you might want to check if you have a virus scanner running.
It usually blocks port 25 which gives you that "An existing connection was forcibly closed by the remote host".
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
I do have a virus scanner. Its Norton.... I will check that too.
Thanks for the help.
|
|
|
|
|
how can it possible to rename a treenode at runtime..in vb.net...
|
|
|
|
|
i got to know its very easy,, just,,
find the node at the point you click and,, then use BEGINEDIT option of the node,.. but dont forget to chage LABLEEDIT propety of the treeview to TRUE
|
|
|
|
|
Hello Everybody,
I need help from all of u, pls help me for following code.
I have given number for each line, only for ref. When u copy the code, pls remove the numbers given and do modification.
The original code is in C# that converted into VB.net using converter.This code is perfectly working in C# without any error and waring Now I'm facing problem.
Now problem is, the line number 20 need raiseEvent, I don't know how to raise event in vb.net
Pls concentrate on line 20. Pls let me know how to declare and raise event.
1 Public Class CreateItemTemplateRadioButton
2 Implements ITemplate
3 Dim strText As String
4 Dim strRadioButtonName As String
5 Dim Visibility As Boolean = True
6 Dim blChecked As Boolean = False
7 Public Sub New(ByVal RadioButtonName As String, ByVal Text As String, ByVal AutoCheck As Boolean)
8 Me.strText = Text
9 Me.strRadioButtonName = RadioButtonName
10 Me.blChecked = AutoCheck
11 End Sub
12 Public Sub New(ByVal RadioButtonName As String, ByVal Text As String, ByVal AutoCheck As Boolean, ByVal Visibility As Boolean)
13 Me.strText = Text
14 Me.strRadioButtonName = RadioButtonName
15 Me.Visibility = Visibility
16 Me.blChecked = AutoCheck
17 End Sub
18 Public Sub InstantiateIn(ByVal objcontainer As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
19 Dim rad As HtmlInputRadioButton = New HtmlInputRadioButton
20 rad.DataBinding += New EventHandler(rad_DataBinding)
21 objContainer.Controls.Add(rad)
22 End Sub
23 Private Sub rad_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
24 Dim rad As HtmlInputRadioButton = CType(sender, HtmlInputRadioButton)
25 rad.Value = strText
26 rad.Checked = blChecked
27 rad.Visible = Visibility
28 End Sub
29 End Class
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|
|
Hi All,
Can anyone tell me how to find out the location of System32 folder programmatically?
Thanks and Regards,
Anil
|
|
|
|
|
If you are using vb.net
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.System))
|
|
|
|
|
Hi there,
I am trying to make this work for the past three days but with no success. I have a windows form application with web browser control integrated into it. What i want is that when ever there is some file download request come along i get the url and download it via System.net classes, if the file is a word,excel or power point document i open them in my other form where i have integrated the word/excel/pp. all the rest of bits are working the only thing left is that i don't know how to intercept file download. I know i have to implement idownloadmanager interface but i can't make it work, my the download method of the interface never get called. the sample code is here
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Browser As AxSHDocVw.AxWebBrowser
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Browser = New AxSHDocVw.AxWebBrowser
CType(Me.Browser, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Browser
'
Me.Browser.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Browser.Enabled = True
Me.Browser.Location = New System.Drawing.Point(8, 8)
Me.Browser.OcxState = CType(resources.GetObject("Browser.OcxState"), System.Windows.Forms.AxHost.State)
Me.Browser.Size = New System.Drawing.Size(360, 304)
Me.Browser.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(376, 318)
Me.Controls.Add(Me.Browser)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.Browser, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As System.Object = "http://my.mindvision.com/~ben/tools/"
Dim o As System.Object = Nothing
Browser.Navigate2(url, o, o, o, o)
SetDownloadManager()
End Sub
Private m_DownloadManagerCookie As System.Int32
Private Sub SetDownloadManager()
Dim ips As COMVB.IProfferService
Dim objBrowser As Object
Dim ispBrowser As COMVB.UCOMIServiceProvider
Dim ip As IntPtr
Try
' Get a handle to the browser ocx
objBrowser = Browser.GetOcx()
ispBrowser = DirectCast(objBrowser, COMVB.UCOMIServiceProvider)
' Query the browser for the IProfferService interface
ip = ispBrowser.QueryService(COMVB.SID_SProfferService, COMVB.IID_IProfferService)
ips = DirectCast(Marshal.GetObjectForIUnknown(ip), COMVB.IProfferService)
' Proffer the new object as the provider of the IHTMLEditHostinterface handler
ips.ProfferService(COMVB.IID_IDownloadManager, New ServiceProvider, m_DownloadManagerCookie)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Class ServiceProvider
Implements COMVB.UCOMIServiceProvider
Public Function QueryService(ByRef guidService As System.Guid, ByRef riid As System.Guid) As IntPtr Implements COMVB.UCOMIServiceProvider.QueryService
If guidService.Equals(COMVB.IID_IDownloadManager) Then
If riid.Equals(COMVB.IID_IDownloadManager) Then
Dim idm As COM.Interfaces.IDownloadManager
idm = New DownloadManager
' idm.Download()
Return GetInterface(idm, COMVB.IID_IDownloadManager)
Else
Return Nothing
End If
Else
Return Nothing
End If
End Function
Public Function GetInterface(ByVal obj As Object, ByRef iid As Guid) As IntPtr
Dim pUnk As IntPtr
Dim pInterface As IntPtr
Dim hr As Integer
pUnk = Marshal.GetIUnknownForObject(obj)
hr = Marshal.QueryInterface(pUnk, iid, pInterface)
If hr < 0 Then
Marshal.ThrowExceptionForHR(hr)
End If
' Marshal.GetHINSTANCE()
' Marshal.Release(pUnk)
Return pInterface
End Function
End Class
Class DownloadManager
Implements COM.Interfaces.IDownloadManager
Public Function Download(ByVal pmk As System.Runtime.InteropServices.UCOMIMoniker, ByVal pbc As System.Runtime.InteropServices.UCOMIBindCtx, ByVal dwBindVerb As System.UInt32, ByVal grfBINDF As Integer, ByVal pBindInfo As System.IntPtr, ByVal pszHeaders As String, ByVal pszRedir As String, ByVal uiCP As System.UInt32) As Integer Implements COM.Interfaces.IDownloadManager.Download
MsgBox("file download event")
Return New System.Int32
End Function
End Class
Class COMVB
' IServiceProvider interface
<comvisible(true), comimport(),guid("6d5140c1-7436-11ce-8034-00aa006009fa"),="" _
interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface UCOMIServiceProvider
Function QueryService(ByRef guidService As Guid, ByRef riid As Guid) As IntPtr
End Interface
' IProfferService interface
<comvisible(true), comimport(),="" guid("cb728b20-f786-11ce-92ad-00aa00a74cd0"),="" _
="" interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface IProfferService
Sub ProfferService(ByRef guidService As Guid, ByVal psp As UCOMIServiceProvider, ByRef cookie As Integer)
Sub RevokeService(ByVal cookie As Integer)
End Interface
Public Shared SID_SProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared IID_IProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared SID_SHTMLEditHost As New Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b")
Public Shared IID_IDownloadManager As New Guid("988934A4-064B-11D3-BB80-00104B35E7F9")
End Class
|
|
|
|
|