|
Mostrar Temas
|
Páginas: 1 [2] 3
|
11
|
Programación / Programación Visual Basic / paso de valores de clase a form
|
en: 10 Marzo 2008, 11:04 am
|
Hola: resulta que tengo el siguiente código, lo que hago es lanzar un form para que el usuario meta valores y luego pasarselos al .class pero no se porque no me coge el string. El codigo del .class es el siguiente: '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
Dim f As New Form1
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 "" nPath = "empty" closing = False
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 ' Create test script template
' this example
Dim myf As String Dim path As String 'The form is loaded f.Execute path = f.getpath If closing = True Then Unload Form1 End If LocalPath = "c:\temp" myf = "C:\temp\batch.bat"
Open myf For Output As #1
Print #1, "cd \ " & vbCrLf & path & vbCrLf & "pause" Print #1, "La ruta es " & path Print #1, "La ruta es " & nPath Close #1 CreateScriptTemplate = 1
End Function
Private Sub Form_Unload(Cancel As Integer)
'on closing the form set the object f to point to nothing
Set f = Nothing
End Sub
Public Function GetBitmap(Status As Long) As Long
GetBitmap = 0 'no bitmap
End Function
Tengo tambien un archivo .bas: Option Explicit
'global variable which stores the item
Public nPath As String
Public closing As Boolean
Y el codigo del form: Option Explicit Dim pathDef As String
'This method show the form Public Sub Execute() Form1.Show End Sub
Private Sub Command1_Click() Dim path As String 'If Option1 button is selected If Option1.Value = True Then 'Dialog box to interact with the user and get the data Do path = InputBox("Enter the path where Nunit is installed:", "Path needed") Loop Until path <> "" pathDef = path MsgBox "Has introducido " & pathDef nPath = pathDef MsgBox "Has introducido " & nPath Command2.Enabled = True End If 'If Option2 is selected If Option2.Value = True Then 'Dialog box to interact with the user and get the data Do path = InputBox("Enter the path where you have your tests located:", "Path needed") Loop Until path <> "" pathDef = path Command2.Enabled = True End If End Sub
Public Function getpath() As String
'function that gets the item selected in the drop-down box
nPath = pathDef
End Function
Private Sub Command2_Click()
closing = True
End Sub
Cuando lanzo el cuadro de dialogo en el form, la variable contiene el string, pero no se porque razon no crea el archivo de texto. Luego tambien me gustaria saber como se podria hacer para que cuando el form sea lanzado el otro programa quede inactivo hasta terminar la ejecucion del form Gracias y Saludos
|
|
|
12
|
Programación / Programación Visual Basic / problema con DCOM en VB
|
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
|
|
|
13
|
Programación / Programación Visual Basic / ejecutar programa en VB
|
en: 1 Febrero 2008, 23:41 pm
|
Hola: Me gustaria saber si es posible crear una ventana en Visual basic y ejecutar un programa externo, pero el programa debe ejecutarse "dentro" de esa ventana Es que conozco la instruccion Shell, pero esa no me vale Saludos
|
|
|
14
|
Programación / Programación Visual Basic / problema con inputbox
|
en: 31 Enero 2008, 11:08 am
|
Hola tengo el siguiente codigo en VB: Public 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 tema es que se me cuelga, supongo que sea por el inputbox porque antes funcionaba bien. ¿Como podria hacerlo funcionar o que puede estar mal aqui? El proyecto es un exe activeX Gracias y Saludos
|
|
|
15
|
Programación / Programación Visual Basic / tratamiento de errores en VB
|
en: 24 Enero 2008, 15:00 pm
|
Hola: Tengo un programa en VB y quiero que cuando se produzca un error se guarde un aviso en un archivo de texto, pero no se xq aunque la ejecucion sea correcta me aparece en el archivo que se ha producido un error, el codigo es este: Exit Function
runErr:
Dim msg$
On Error Resume Next
msg = "Error in run: " & Err.Description
LogFile.WriteLine msg
On Error GoTo runErr
Resume Next
End Function
Se supone que si hay algun error el programa va a la etiqueta y guarda el error y continua con la ejecucion del programa no¿ Hay mas cido antes de la etiqueta pero creo q no es necesario ponerlo aqui Gracias y Saludos
|
|
|
16
|
Media / Multimedia / Duda al grabar pelis
|
en: 23 Agosto 2007, 02:20 am
|
Hola tengo la siguiente duda, aver si me la podeis resolver: Resulta que muchas veces que me descargo alguna peli al ir a grabarla con el Nero, creando CD de video el tamaño se me sale de un CD normal, y solo puedo grabarla como datos. Esto por qué pasa?Cómo solucionarlo o qué tengo q buscar en las pelis al descargarlas para que no me pase esto?¿ Gracias y Saludos!!
|
|
|
17
|
Programación / Java / fichero aleatorios java
|
en: 8 Diciembre 2006, 04:31 am
|
hola , tengo una duda con los ficheros aleatorios en java Es posible sustituir una linea o un array de bytes q ye estan en el archivo por otros q yo le pase por parametro. O tengo q copiar el archivo entero hasta esa linea en un archivo auxiliar añadir lo que yo kiera y volver a copiarlo al original Gracias
|
|
|
18
|
Programación / PHP / mas problemas con php
|
en: 26 Octubre 2006, 07:22 am
|
Hola, sigo con mi carrito, al final lo unico q tengo q hacer es permitir coger los productos de 1 en 1 y poer seleccionar ingredientes. el problema que tengo es que si cojo por ejemplo 2 hamburguesas con disitintos ingredientes me los trata cmo productos iguales y yo quiero q los trate cmo productos distintos y q los liste tb cmo productos distintos. Os pego el codigo: <?php 2 // start session 3 session_start(); 4 5 // initialize session shopping cart if you are connecting for the first time 6 if (!isset($_SESSION['cart'])) 7 { 8 $_SESSION['cart'] = array(); 9 } 10 11 12 // Specify the name of the file containing data 13 $catalogFile = "catalog.dat"; 14 // if file is available, extract data from it 15 // place into $CATALOG array, with SKU as key 16 if (file_exists($catalogFile)) //does the file exist 17 { 18 $data = file($catalogFile); //read entire file into array. Each line occupies 19 //one array slot. NOT good if file is large. 20 foreach ($data as $line) 21 { 22 $lineArray = explode(':', $line); //lineArray contain three items: SKU, 23 //description, and price 24 $sku = trim($lineArray[0]); 25 $CATALOG[$sku]['desc'] = trim($lineArray[1]); //trim removes extra white 26 $CATALOG[$sku]['price'] = trim($lineArray[2]);//space from either end 27 } 28 } 29 // file is not available 30 // stop immediately with an error 31 else 32 { 33 die("Could not find catalog file"); 34 } 35 36 // check to see if the form has been submitted 37 // and which submit button was clicked 38 39 // if this is an add operation 40 // add to already existing quantities in shopping cart 41 if ($_POST['add']) 42 { 43 foreach ($_POST['a_qty'] as $k => $v) 46 { 47 // if the value is 0 or negative 48 // don't bother changing the cart 49 if ($v > 0) //occurs if user entered data 50 { 51 52 //i get the ingredients if there are meals selected 53 if ($k==101) 54 { 55 $newstring = "Hamburguer"; 56 foreach ($_POST['ing'] as $o) 57 $newstring = $newstring . " " . $o; 58 } 59 //line below tracks number of each item ordered 60 $_SESSION['cart'][$k] = $_SESSION['cart'][$k] + $v; 61 62 63 64 } 65 } 66 } 67 // if this is an update operation 68 // replace quantities in shopping cart with values entered 69 else if ($_POST['update']) 70 { 71 foreach ($_POST['u_qty'] as $k => $v) 72 { 73 // if the value is empty, 0 or negative 74 // don't bother changing the cart 75 if ($v != "" && $v >= 0) 76 { 77 $_SESSION['cart'][$k] = $v; 78 } 79 } 80 } 81 // if this is a clear operation 82 // reset the session and the cart 83 // destroy all session data 84 else if ($_POST['clear']) 85 { 86 $_SESSION = array(); 87 session_destroy(); 88 } 90 ?> 91 <html> 92 <head></head> 93 <body> 94 95 <h2>Catalog</h2> 96 Please add items from the list below to your shopping cart. 97 98 <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 99 <table border="0" cellspacing="10"> 100 <?php 101 // print items from the catalog for selection 102 foreach ($CATALOG as $k => $v) 103 { 104 echo "<tr><td colspan=2>"; 105 echo "<b>" . $v['desc'] . "</b>"; 106 echo "</td></tr>\n"; 107 echo "<tr><td>"; 108 echo "Price per unit: " . $CATALOG[$k]['price']; 109 echo " Quantity: "; 110 echo "<input size=4 type=text name=\"a_qty[" . $k . "]\">"; 111 echo "</td></tr><tr><td>"; 112 //if the item is a hamburguer y have to show the extra ingredients 113 if ($k==101) 114 { 115 echo " Please select the extra ingredients that you want (FREE!!):</td><td>"; 116 echo " <input type='checkbox' name='ing[]' value='Onions'> Onions</td><td>"; 117 echo " <input type='checkbox' name='ing[]' value='Ketchup'> Ketchup</td><td>"; 118 echo " <input type='checkbox' name='ing[]' value='Pickles'> Pickles</td><td>"; 119 echo " <input type='checkbox' name='ing[]' value='Mustard'> Mustard</td><td>"; 120 echo " </tr></td>"; 121 } 122 //the same if the item is a hamburguer with cheese 123 elseif($k==102) 124 { 125 echo " Please select the extra ingredients that you want (FREE!!):</td><td>"; 126 echo " <input type='checkbox' name='ing2[]' value='Onions'> Onions</td><td>"; 127 echo " <input type='checkbox' name='ing2[]' value='Ketchup'> Ketchup</td><td>"; 128 echo " <input type='checkbox' name='ing2[]' value='Pickles'> Pickles</td><td>"; 129 echo " <input type='checkbox' name='ing2[]' value='Mustard'> Mustard</td><td>"; 130 echo " </td></tr>"; 131 } 132 //the same if the item is a hotdog 133 elseif ($k==103) 134 { 135 echo " Please select the extra ingredients that you want (FREE!!):</td><td>"; 136 echo " <input type='checkbox' name='ing3[]' value='Onions'> Onions</td><td>"; 137 echo " <input type='checkbox' name='ing3[]' value='Ketchup'> Ketchup</td><td>"; 138 echo " <input type='checkbox' name='ing3[]' value='Pickles'> Pickles</td><td>"; 139 echo " <input type='checkbox' name='ing3[]' value='Mustard'> Mustard</td><td>"; 140 echo " </td></tr>"; 141 } 142 echo "</td></tr>"; 143 144 145 } 146 ?> 147 <tr> 148 <td colspan="2"> 149 <input type="submit" name="add" value="Add items to cart"> 150 </td> 151 </tr> 152 </table> 153 154 <hr /> 155 <hr /> 156 157 <h2>Shopping cart</h2> 158 159 <table width="100%" border="0" cellspacing="10"> 160 <?php 161 // initialize a variable to hold total cost 162 $total = 0; 163 // check the shopping cart 164 // if it contains values (It COULD be empty) 165 // look up the SKUs in the $CATALOG array 166 // get the cost and calculate subtotals and totals 167 if (is_array($_SESSION['cart'])) 168 { 169 foreach ($_SESSION['cart'] as $k => $v) 170 { 171 // only display items that have been selected 172 // that is, quantities > 0 173 if ($v > 0) 174 { 175 $subtotal = $v * $CATALOG[$k]['price']; 176 $total += $subtotal; 177 echo "<tr><td>"; 178 echo "<b>$v unit(s) of " . $CATALOG[$k]['desc'] . "</b>"; 179 180 /*//normal hamburguer 181 if ($k==101) 182 if (is_array($_POST['ing'])) 183 { 184 echo " with: "; 185 //foreach to read the elements 186 foreach ($_POST ['ing'] as $o) 187 { 188 echo " $o "; 189 } 190 } 191 //cheese hamburguer 192 if ($k==102) 193 if (is_array($_POST['ing2'])) 194 { 195 echo " with: "; 196 //foreach to read the elements 197 foreach ($_POST ['ing2'] as $o) 198 { 199 echo " $o "; 200 } 201 } 202 //hotdog 203 if ($k==103) 204 if (is_array($_POST['ing3'])) 205 { 206 echo " with: "; 207 //foreach to read the elements 208 foreach ($_POST ['ing3'] as $o) 209 { 210 echo " $o "; 211 } 212 }*/ 213 214 echo "</td><td>"; 215 echo "New quantity: <input size=4 type=text name=\"u_qty[" . $k . "]\">"; 216 echo "</td></tr>\n"; 217 echo "<tr><td>"; 218 echo "Price per unit: " . $CATALOG[$k]['price']; 219 echo "</td><td>"; 220 echo "Sub-total: " . sprintf("%0.2f", $subtotal); 221 echo "</td></tr>\n"; 222 } 223 } 224 } 225 ?> 226 <tr> 227 <td><b>Total without taxes</b></td> 228 <td><b><?=sprintf("%0.2f", $total)?></b></td> 229 </tr> 230 <br> 231 <tr> 232 <td>Taxes</td> 233 <? $taxes = $total * 0.055; ?> 234 <td><?=sprintf("%0.2f", $taxes) ?></td> 235 </tr> 236 <br> 237 <td><b>TOTAL</b></td> 238 <? $totaldef = $total + $taxes; ?> 239 <td><b><?=sprintf("%0.2f", $totaldef) ?></b></td> 240 </tr> 241 <br> 242 243 244 <tr> 245 <td><input type="submit" name="update" value="Update Cart"></td> 246 <td><input type="submit" name="clear" value="Clear Cart"></td> 247 </tr> 248 </table> 249 </form> 250 251 </body> 252 </html>
Gracias x adelantado. Saludos
|
|
|
19
|
Programación / PHP / php
|
en: 25 Octubre 2006, 08:50 am
|
Hola tengo una duda con php, aver si alguine me puede ayudar: Quiero hacer el tipico carrito de la compra, pero con una excepcion, cuando tu escoges un objeto, quiero q se puedan escoger opciones para ese objeto. Os pongo un ejemplo: Por ejemplo uno de los objetos es una Hamburguesa. Cuando tu añades una hamburguesa a tu carrito tienes q poder añadir ingredientes extra, si tu escoges 2 hamburguesas las 2 pueden llevar ingredientes distintos. Me he explicado¿? Gracias x adelantado. Saludos! Sorry por el mensaje de antes :S
|
|
|
20
|
Programación / Scripting / script linux
|
en: 19 Septiembre 2006, 21:53 pm
|
Hola a todos. estoy haciendo un script en linux que hace backups de un directorio dado. Pero me pasaalgo curioso al ejecutar el script ademas de los archivos q yo tengo en el directorio siempre me aparecen otros con el mismo nombre y el signo ~. A que se debe esto?¿? Este es mi codigo: #!/bin/bash ##This script makes a backup of an especified directory ##Programmed by Raúl Sánchez
##I check the parameters
if [ $# -ne 1 ] then echo You must enter a valid directory echo usage: $0 directory exit 1 fi
dir=$1 ##dir is the directory specified by the first parameter
## make sure $dir is a directory (not a file) and has write privilege if [ ! -d $dir ] || [ ! -w $dir ] then echo $dir not a writable directory exit 1 fi
##I enter into the directory cd $dir
files=* ## variable files expands to include a list of all files ## in the directory
## examine all files in the directory ## to the user for file in $files do ## take a look at every file if [ ! -f $file ] then ## if not an ordinary file then skip continue ## treat only ordinary files fi echo " " ## gives a blank line ls -l $file ## list file and its attributes while [ 1 ] ## infinite loop do echo "***** Do you want to create a backup of $file??" echo -n "[y(yes), n(no)]" ## " is necessary to avoid misinterpreting * read c case $c in ## what did user select y) ## yes -- I create the backup if [ ! -r $file ] then ## can I read this file? echo cannot read $file else cp $file $file.bak ##copy the file echo "***** $file saved" fi break;; ## to handle next file n) ## no, don't save file echo "***** $file not saved" break;; ## to handle next file esac done ## while loop done ## for loop exit 0
Gracias y Saludos
|
|
|
|
|
|
|