d.pereira Posted June 11, 2012 Report Share Posted June 11, 2012 Olá Eu gostaria de saber, quando a listbox lê-se um arquivo de texto eu queria que fosse automaticamente, em vez de meter um botão e abri-lo pelo open file, entenderam? Link to comment Share on other sites More sharing options...
acao Posted June 12, 2012 Report Share Posted June 12, 2012 boas se percebi não queres clicar no botão, sugestão: colocas o cod no evento load do form. «ao abrir carrega o ficheiro» cumps acao Link to comment Share on other sites More sharing options...
d.pereira Posted June 13, 2012 Author Report Share Posted June 13, 2012 Muito obrigada 🙂 . Mas também gostava de saber se era possível se o arquivo .txt abri-se automaticamente na listbox, se me poderem responder agradecia é que estou num trabalho de estágio. Os meus melhores cumprimentos, Diogo Link to comment Share on other sites More sharing options...
acao Posted June 13, 2012 Report Share Posted June 13, 2012 boas foi isso que eu sugeri colocas o cod no evento load do form e mostras o texto no listbox. cumps acao Link to comment Share on other sites More sharing options...
d.pereira Posted June 14, 2012 Author Report Share Posted June 14, 2012 Sim, eu percebi mas queria que aparecesse sem o openfile. Seria possível isso? Queres que meta aqui o código, para ser mais rápido? Cumps Diogo Link to comment Share on other sites More sharing options...
acao Posted June 14, 2012 Report Share Posted June 14, 2012 (edited) boas tens que usar sempre código para carrega-lo, não dá directamente nas propriedades. podes usar a função freefile, mas vai dar mais ou menos a mesma coisa, o ficheiro tem que ser aberto. tens aqui um exemplo do macoratti. http://www.macoratti.net/arq_fun.htm e tens aqui outro com o open file. http://www.macoratti.net/vbn_atd1.htm cumps acao Edited June 14, 2012 by acao Link to comment Share on other sites More sharing options...
d.pereira Posted June 19, 2012 Author Report Share Posted June 19, 2012 Imports Impress.My.Resources Public Class Form1 Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Const PRINTER_ATTRIBUTE_SHARED As Long = &H8 Private Const PRINTER_ATTRIBUTE_LOCAL As Long = &H40 Private Const PRINTER_ATTRIBUTE_NETWORK = &H10 Private Const PRINTER_LEVEL2 As Long = &H2 Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000 Private Const PRINTER_ACCESS_ADMINISTER As Long = &H4 Private Const PRINTER_ACCESS_USE As Long = &H8 Private Const PRINTER_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or _ PRINTER_ACCESS_ADMINISTER Or _ PRINTER_ACCESS_USE) Private Structure PRINTER_DEFAULTS pDatatype As String pDevMode As Long 'DEVMODE DesiredAccess As Long End Structure Private Structure PRINTER_INFO_2 Dim pServerName As String Dim pPrinterName As String Dim pShareName As String Dim pPortName As String Dim pDriverName As String Dim pComment As String Dim pLocation As String Dim pDevMode As Long 'DEVMODE Dim pSepFile As String Dim pPrintProcessor As String Dim pDatatype As String Dim pParameters As String Dim pSecurityDescriptor As Long 'SECURITY_DESCRIPTOR Dim Attributes As Long Dim Priority As Long Dim DefaultPriority As Long Dim StartTime As Long Dim UntilTime As Long Dim Status As Long Dim cJobs As Long Dim AveragePPM As Long End Structure Private Declare Function AddPrinter Lib "winspool.drv" _ Alias "AddPrinterA" _ (ByVal pServerName As String, _ ByVal Level As Long, _ ByVal pPrinter As Long) As Long Private Declare Function OpenPrinter Lib "winspool.drv" _ Alias "OpenPrinterA" _ (ByVal pPrinterName As String, _ ByVal phPrinter As Long, _ ByVal pDefault As Long) As Long Private Declare Function DeletePrinter Lib "winspool.drv" _ (ByVal hPrinter As Long) As Long Private Declare Function ClosePrinter Lib "winspool.drv" _ (ByVal hPrinter As Long) As Long Private Sub Form_Load() Command1.Caption = "Add Printer" Command2.Caption = "Delete Printer" Label1.Caption = "" End Sub Private Sub Command1_Click() Dim hPrinter As Long Dim sServer As String Dim pi2 As PRINTER_INFO_2 With pi2 'local machine .pServerName = vbNullString 'display name for new printer .pPrinterName = "vbnet test printer" 'name for share - must be upper-case .pShareName = "HPLJ601" 'printer port (NT or later can 'have multiple separated with 'commas, e.g. "LPT1:,LPT2:") .pPortName = "LPT1:" 'the name of an existing driver .pDriverName = "HP LaserJet 5Si MX" 'a comment, if desired .pComment = "Test printer - can delete" 'the location, if desired .pLocation = "Bldg 7, Room 1321, NW601" 'the print processor name - manditory .pPrintProcessor = "WinPrint" 'type of data supported, e.g. RAW or EMF 'this must match type used by the driver '- manditory .pDatatype = "RAW" 'flags - local printer, with share created .Attributes = PRINTER_ATTRIBUTE_LOCAL Or _ PRINTER_ATTRIBUTE_SHARED End With 'install on the local machine by passing 'vbNullString as the server name. If 'installation on another machine is 'to be made, pass the machine name 'in the usual 'server name format', 'eg: sServer = "\\laptopxp" sServer = vbNullString hPrinter = AddPrinter(sServer, PRINTER_LEVEL2, pi2) Debug.Print(hPrinter, Err.LastDllError) If hPrinter <> 0 Then Label1.Caption = "Printer added successfully" ClosePrinter(hPrinter) End If End Sub Private Sub Command2_Click() Dim hPrinter As Long Dim sPrinterName As String Dim pd As PRINTER_DEFAULTS 'we're deleting the just-added local printer, 'so specify the same printer name as used 'for pi2.pPrinterName during AddPrinter sPrinterName = "vbnet test printer" 'if the printer to be deleted is on another 'machine, the machine and printer are passed 'together as sPrinterName in the format '\\computername\printername, e.g. ' sPrinterName = sServer & "\" & sPrinterName 'or for our demo, ' sPrinterName = "\\laptopxp\vbnet test printer" 'set up a printer_defaults structure With pd 'no devmode, so UDT member is 'declared Long and a null is passed .pDevMode = 0& 'must be datatype of printer driver 'as set in AddPrinter .pDatatype = "RAW" 'this is the access level for delete .DesiredAccess = PRINTER_ALL_ACCESS End With If OpenPrinter(sPrinterName, hPrinter, pd) <> 0 Then If hPrinter <> 0 Then If DeletePrinter(hPrinter) <> 0 Then Label1.Caption = "Printer deleted" End If 'DeletePrinter End If 'hPrinter ClosePrinter(hPrinter) End If 'OpenPrinter Debug.Print(hPrinter, Err.LastDllError) End Sub End Class Boas, Eu estou a tentar instalar e adicionar impressoras ao programa e a minha dúvida é a seguinte : Eu meto este código no form e acrescentei a label só que me dá errado. Será que alguém me poderia ajudar? Agradecia Os meus melhores comprimentos, Diogo Link to comment Share on other sites More sharing options...
acao Posted June 19, 2012 Report Share Posted June 19, 2012 boas Diogo eu não te consigo ajudar, mas como o assunto parece diferente, ou aguardas que mais alguém se pronuncie, nomedamente o JPaulino que povavelmente passará por aqui, ou abre noutro tópico, se for net ou vb6 existe local próprio neste forum. cumps acao Link to comment Share on other sites More sharing options...
d.pereira Posted June 20, 2012 Author Report Share Posted June 20, 2012 Boas, Obrigado pelo ajuda que me deste já foi muito. 🙂 Os meus melhores comprimentos, D. Pereira Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now