Título: problema con DCOM en VB
Publicado por: ^kazike^ en 19 Febrero 2008, 15:07 pm
Hola, tengo el siguiente codigo: ublic Function CreateScriptTemplate(TestKey As Long, _ ByRef LocalPath As String) As Long ' Create a batch file to emulate a test script for
' this example
Dim myf As String Dim path As String
LocalPath = "c:\temp"
myf = "C:\temp\batch.bat" 'user must input the nunit path to can execute it path = InputBox("Enter the path where Nunit is intalled:", "Path needed") While (path = "") path = InputBox("Enter the path where Nunit is intalled:", "Path needed") Wend
Open myf For Output As #1
Print #1, "cd C:\Archivos de Programa\NUnit 2.4.5\bin" & vbCrLf & "nunit.exe" & vbCrLf & "pause" Close #1
CreateScriptTemplate = 1
End Function
El caso es que al llegar al bucle se cuelga, no se por qué. El proyecto es un exe activeX y es lanzado por otra aplicacion, no se si eso influirá, porque no creo ningun form ni na de eso Gracias y Saludos
Título: Re: problema con DCOM en VB
Publicado por: pana88 en 24 Febrero 2008, 18:31 pm
la respuesta es obvia si pone bien o mal el path vb va a volver a repetir el bucle ... pone algun of para que salga del bucle por que o sino siempre va avolver a hacer lo mismo es por eso que se cuelga
Título: Re: problema con DCOM en VB
Publicado por: Chefito en 24 Febrero 2008, 22:02 pm
Que va. Ese codigo está bien.Debería funcionar bien (por lo menos en un proyecto EXE. En un activeX no tengo ni idea.....aunque no veo porque va a ir mal eso :-\). Hazlo paso a paso en el depurador a ver si ves que ocurre. pana88 el bucle si acaba. Se repite mientras la variable path esté vacía (vamos, que no pones nada en el inputbox) yo lo haría así, ya que por narices tiene que hacerlo una vez por lo menos: Do path = InputBox("Enter the path where Nunit is intalled:", "Path needed") loop until path<>"" Saludos.
Título: Re: problema con DCOM en VB
Publicado por: ^kazike^ en 25 Febrero 2008, 13:22 pm
Hola, no he podido encontrar el fallo asi que he decido replantearme el camino a seguir. He creado otro activeX que es llamado por el primero para coger los datos. El problem aes que al compilar me aparece el siguiente error: No se encuentra el miembro o metodo de datos: Este es el codigo: 'These members represent the main TestType object properties.
Public RemoteAgentCLSID As String ' Run Remote Agent Class ID
Public ScriptViewerCLSID As String ' ActiveX script viewer Class ID
Public TestingToolName As String ' Remote Agent name
Public ExecConfigCLSID As String ' Configuration Class ID
Public CanCreateScriptTemplate As Long ' Flag
Public LastErrorMessage As String ' Most common error message
Public ResultViewerCLSID As String ' ActiveX result viewer Class ID
Private td As TDConnection 'variable of type clsActivexEx class in Activex_ex component
'create an object for class clsActivexEx in AxtivexEx component Dim actvixTest As Class1
Private Sub Class_Initialize()
'This sub-routine is run when the TestType is loaded.
'Note that at this time, none of the optional controls is
' supported, as their class ID strings are empty.
'Also note that the remote agent class ID is empty,
' as no such agent yet exists.
'This example does not support script templates,
' and has only one error type.
ExecConfigCLSID = "" ' No configuration utility provided
RemoteAgentCLSID = "{78888EDF-6BCB-4477-AB18-9DA7D483CC52}"
ScriptViewerCLSID = "{472B9CAC-C738-43BE-A0A7-EB6AB1B8BDEA}"
TestingToolName = "Script"
CanCreateScriptTemplate = 1 ' create new test feature turned on
LastErrorMessage = "" ' Testing issues
ResultViewerCLSID = "" ' No result viewer ActiveX provided
LoadPicture ""
End Sub
Public Sub Init(mytd As Variant)
' You may need a TDConnection to use OTA functions in your application.
' If you do, add a project reference to the OTA:
' In Projects > References, check the "OTA COM 8.0 Type Library."
' and declare a module-level variable: Private td As TDConnection
Set td = mytd 'Get the td object to be used if needed
End Sub
Public Function CreateScriptTemplate(TestKey As Long, _ ByRef LocalPath As String) As Long Set actvixTest = New Class1 ' Create a batch file to emulate a test script for
' this example
Dim myf As String Dim path As String
'Load the form to interact with the user and get the data [b]actvixTest.LoadForm[/b] path = actvixTest.getselectedchar actvixTest.Form_Unload LocalPath = "c:\temp"
myf = "C:\temp\batch.bat"
Open myf For Output As #1
Print #1, "cd C:\Archivos de Programa\NUnit 2.4.5\bin" & vbCrLf & "nunit.exe" & vbCrLf & "pause" Print #1, vbCrLf & path Close #1
CreateScriptTemplate = 1
End Function
Public Function GetBitmap(Status As Long) As Long
GetBitmap = 0 'no bitmap
End Function
Private Sub Form_Unload(Cancel As Integer)
'on closing the form set the object actvixTest to point to nothing
'thereby removing reference the class clsActivexEx in component Activex_ex
Set actvixTest = Nothing
End Sub
El error me lo da en "actvixTest.LoadForm" El codigo del .cls del activeX es: Option Explicit
Public Function LoadForm()
'Load the form
Load formActiveX
formActiveX.Caption = formActiveX.Caption
formActiveX.Show
End Function
Private Sub Class_Initialize()
'selectedItem is a global variable declared in module
'set it to nothing initially
'whcih implies that no item has been selected
selectedItem = "nothing"
End Sub
Private Sub Class_Terminate()
'on terminating unload the form
Unload formActiveX
End Sub
Public Function getselectedchar() As String
'function that gets the item selected in the drop-down box
getselectedchar = selectedItem
End Function
Public Sub Form_Unload()
Unload formActiveX
End Sub
Tb he añadido una referencia a este ultimo archivo. Gracias y Saludos
|