Own3d...
Bélissimo tutorial bro :@
Um dia ainda vou aprender VB :S
Abraços,
Caidera
Own3d...
Bélissimo tutorial bro :@
Um dia ainda vou aprender VB :S
Abraços,
Caidera
Loky, Lii e re-lii e continuo não intendendo oque ele faiz.
Tentei fazer no VB mas não acho alguns comandos, poderia me falar qual a função dele ?? Eu sei que você já explicou só que poderia explicar novamente só um pouco mais claro, enquanto vou continuar tentando achar o "Toolbox" e faze a form.
Abraços,
Kendrius.
@Kendrius: Que parte exatamente você não entendeu? :]
Isso aí é somente um tutorial simples de uma utilidade que o VB pode fazer saca? Funciona como o Bloco de Notas do Windows, e realmente só é útil para estudos. ;]
A ToolBox é onde ficam os ícones de adicionar: Botões, TextBoxes, Combos, etc...
Caso não tenha entendido alguma coisa, favor postar. ;]
info
Grupo: Campones
Registrado: 18/03/06
Posts: 22
Reputação: 0
Agora temos o formulário. Para que possamos executar as atividades que são peculiares de um 'editor de texto', utilizaremos o Add-In 'Microsoft Common Dialog Control'.
Por favor onde fica isto??
Ah claro. Pequenos erros... ;]
A propósito, confundi os nomes também, não iremos usar um Add-In, mas sim um Componente ;].
Para inserir o componente use 'Control + T', ou vá ao menu 'Project -> Components'.
=]
Post principal consertado.
Editado Junho 3 por L0ky
info
Grupo: Campones
Registrado: 18/03/06
Posts: 22
Reputação: 0
Mais uma perguntinha,
Onde está esta caixa de texto??
MultLine?
Por que só tem uma aqui.
---
Esquece é burrice minha, é uma propriedade.
Desculpe
Editado Junho 3 por ZkRyXTIBIA
info
Grupo: Campones
Registrado: 26/12/05
Posts: 51
Reputação: 0
Char no Tibia: Falcler Knight

awe fico dahora sua explicaçao
flwss
Que tuto rox
Tem um jeito aki olha
Assim ele pergunta e ainda ver se foi editado e tal
Como ainda to baxando o vb(perdi o cd) vo posta o codigo entero
Em: frmTextEditor.frm(abra pelo notepad)
VERSION 5.00Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"Begin VB.Form frmTextEditor ClientHeight = 4335 ClientLeft = 165 ClientTop = 855 ClientWidth = 5445 LinkTopic = "Form1" ScaleHeight = 4335 ScaleWidth = 5445 StartUpPosition = 3 'Windows Default Begin MSComDlg.CommonDialog ComDlg Left = 510 Top = 390 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.TextBox txtData Height = 3075 Left = 60 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 0 Top = 60 Width = 4575 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileNew Caption = "&New" Shortcut = ^N End Begin VB.Menu mnuFileOpen Caption = "&Open..." Shortcut = ^O End Begin VB.Menu mnuFileSave Caption = "&Save" Shortcut = ^S End Begin VB.Menu mnuFileSaveAs Caption = "Save &As..." End Begin VB.Menu mnuFileMRU Caption = "-" Index = 0 Visible = 0 'False End Begin VB.Menu mnuFileSep Caption = "-" End Begin VB.Menu mnuFileExit Caption = "E&xit" End End Begin VB.Menu mnuEdit Caption = "&Edit" Visible = 0 'False Begin VB.Menu mnuEditCut Caption = "######&t" Shortcut = ^X End Begin VB.Menu mnuEditCopy Caption = "&Copy" Shortcut = ^C End Begin VB.Menu mnuEditPaste Caption = "&Paste" Shortcut = ^V End End Begin VB.Menu mnuSearch Caption = "&Search" Visible = 0 'False Begin VB.Menu mnuSearchFind Caption = "&Find..." Shortcut = ^F End Begin VB.Menu mnuSearchFindAgain Caption = "Find &Again" Shortcut = {F3} End EndEndAttribute VB_Name = "frmTextEditor"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = FalseOption ExplicitPrivate m_blnDirty As BooleanPrivate m_strFilename As StringPrivate m_intMRU As IntegerPrivate m_strSearch As StringPrivate Sub Form_Load()End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If Not SaveComplete Then Cancel = TrueEnd SubPrivate Sub Form_Resize() On Error Resume Next txtData.Width = Me.ScaleWidth - (2 * txtData.Left) txtData.Height = Me.ScaleHeight - (2 * txtData.Top)End SubPrivate Sub mnuEditCopy_Click() Clipboard.SetText txtData.SelTextEnd SubPrivate Sub mnuEditCut_Click() Clipboard.SetText txtData.SelText txtData.SelText = ""End SubPrivate Sub mnuEditPaste_Click() txtData.SelText = Clipboard.GetTextEnd SubPrivate Sub mnuFileExit_Click() Unload MeEnd SubPrivate Sub mnuFileMRU_Click(Index As Integer) If Not SaveComplete() Then Exit Sub m_strFilename = Mid(mnuFileMRU(Index).Caption, 4) LoadFileEnd SubPrivate Sub mnuFileNew_Click() If Not SaveComplete() Then Exit Sub ' ' Clear out the text box ' and reset all variables ' m_strFilename = "" txtData.Text = "" m_blnDirty = FalseEnd SubPrivate Sub mnuFileOpen_Click() If Not SaveComplete() Then Exit Sub ' ' Select file to open using ' Common Dialog control ' On Error GoTo EH With ComDlg .CancelError = True .Filter = "Text Files (*.klg)|*.klg|All Files (*.*)|*.*" .DefaultExt = ".txt" .DialogTitle = "Open File" .FilterIndex = 1 .InitDir = "C:\arkivo.klg" .Flags = cdlOFNHideReadOnly .ShowOpen If .FileName <> "" Then m_strFilename = .FileName End With LoadFile AddToMRUList m_strFilename Exit Sub ' ' This will catch any errors, such ' as when the user hits the Cancel ' button to exit the dialog. 'EH: If Err.Number = cdlCancel Then Exit Sub Else MsgBox "ERROR: " & Err.Description _ & ". [Error #" & Err.Number & "]", vbCritical End If End SubPrivate Sub mnuFileSave_Click() SaveFileEnd SubPrivate Sub mnuFileSaveAs_Click() Dim strTempFilename As String ' ' In case the user cancels out ' of the Save dialog, keep the ' old filename for use. Otherwise ' the new name will be used. ' strTempFilename = m_strFilename m_strFilename = "" SaveFile If m_strFilename = "" Then m_strFilename = strTempFilenameEnd SubPrivate Function SaveComplete() As Boolean Dim intReturn As Integer ' ' If no changes were made, exit immediately. ' If Not m_blnDirty Then SaveComplete = True Exit Function End If ' ' Prompt user to save data ' intReturn = MsgBox("You have changed this text. Do you want to save it?", _ vbExclamation + vbYesNoCancel) Select Case intReturn Case vbYes ' save file and continue SaveFile SaveComplete = True Case vbNo ' don't save file but continue m_blnDirty = False SaveComplete = True Case vbCancel ' don't continue SaveComplete = False End Select End FunctionPrivate Sub SaveFile() Dim objFSO As New Scripting.FileSystemObject Dim objStream As Scripting.TextStream On Error GoTo EH ' ' If filename is empty, prompt for a filename to use ' If m_strFilename = "" Then With ComDlg .CancelError = True .Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" .DefaultExt = ".txt" .DialogTitle = "Save File" .FilterIndex = 1 .Flags = cdlOFNHideReadOnly .ShowSave If .FileName <> "" Then m_strFilename = .FileName End With End If ' ' Open the file and write out the text to it. ' Set objStream = objFSO.OpenTextFile(m_strFilename, _ ForWriting, True) objStream.Write txtData.Text objStream.Close m_blnDirty = False Exit Sub ' ' Handle any errors that might occurEH: If Err.Number = cdlCancel Then Exit Sub Else MsgBox "ERROR: " & Err.Description _ & ". [Error #" & Err.Number & "]", vbCritical End IfEnd SubPrivate Sub AddToMRUList(strFilename As String) Dim i As Integer mnuFileMRU(0).Visible = True If m_intMRU < 4 Then Load mnuFileMRU(m_intMRU + 1) m_intMRU = m_intMRU + 1 End If For i = m_intMRU - 1 To 1 Step -1 mnuFileMRU(i + 1).Caption = "&" & (i + 1) & " " _ & Mid(mnuFileMRU(i).Caption, InStr(mnuFileMRU(i).Caption, " ") + 1) Next i With mnuFileMRU(1) .Caption = "&1 " & strFilename .Visible = True End WithEnd SubPrivate Sub LoadFile() Dim objFSO As New Scripting.FileSystemObject Dim objStream As Scripting.TextStream Set objStream = objFSO.OpenTextFile(m_strFilename, _ ForReading, False) txtData.Text = objStream.ReadAll objStream.Close Set objFSO = Nothing m_blnDirty = FalseEnd SubPrivate Sub mnuSearchFind_Click() Dim lngPos As Long m_strSearch = InputBox("Enter the text to find.", "Find Text") If m_strSearch = "" Then Exit Sub lngPos = InStr(1, txtData.Text, m_strSearch, vbTextCompare) If lngPos > 0 Then txtData.SelStart = lngPos - 1 txtData.SelLength = Len(m_strSearch) Else m_strSearch = "" MsgBox "Search text was not found.", vbExclamation End IfEnd SubPrivate Sub mnuSearchFindAgain_Click() Dim lngPos As Long If m_strSearch = "" Then Call mnuSearchFind_Click lngPos = InStr(txtData.SelStart + txtData.SelLength, txtData.Text, m_strSearch, vbTextCompare) If lngPos > 0 Then txtData.SelStart = lngPos - 1 txtData.SelLength = Len(m_strSearch) Else m_strSearch = "" MsgBox "Search text was not found.", vbExclamation End If End SubPrivate Sub txtData_Change() m_blnDirty = TrueEnd Sub
Em :MSSCCPRJ.SCC
[sCC]SCC=This is a source code control file[TextEditor.vbp]SCC_Project_Name=this project is not under source code controlSCC_Aux_Path=<This is an empty string for the mssccprj.scc file>
Em:TextEditor.vbp
Type=ExeReference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE AutomationReference=*\G{420B2830-E718-11CF-893D-00A0C9054228}#1.0#0#C:\WINNT\System32\scrrun.dll#Microsoft Scripting RuntimeObject={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; comdlg32.ocxForm=frmTextEditor.frmStartup="frmTextEditor"Command32=""Name="TextEditor"HelpContextID="0"CompatibleMode="0"MajorVer=1MinorVer=0RevisionVer=0AutoIncrementVer=0ServerSupportFiles=0VersionCompanyName="Northstar Computer Systems"CompilationType=0OptimizationType=0FavorPentiumPro=0CodeViewDebugInfo=0NoAliasing=0BoundsCheck=0OverflowCheck=0FlPointCheck=0FDIVCheck=0UnroundedFP=0StartMode=0Unattended=0Retained=0ThreadPerObject=0MaxNumberOfThreads=1[MS Transaction Server]AutoRefresh=1
Em: TextEditor.vbw
frmTextEditor = 44, 44, 599, 371, Z, 22, 22, 577, 349, C
E isso ai ja vai tar tudo config so abrir pelo vb agora ^^
info
Grupo: Campones
Registrado: 09/07/05
Posts: 26
Reputação: 0
Olá à todos.
Neste tópico, iremos avançar um pouco os nossos conhecimentos de Visual Basic e criaremos um programa que lê, edita e salva, e cria novos documentos de texto.
Vamos aos passos:
1. Abra o VB e inicie uma aplicação normal. (Standard Exe)
Agora temos o formulário. Para que possamos executar as atividades que são peculiares de um 'editor de texto', utilizaremos o Componente 'Microsoft Common Dialog Control'. Para isso digite 'Contrlol + T' ou pelos menus: 'Project -> Components'. (Vide figura 1)
Figura 1
Agora, Insira 2 Botões e uma caixa de texto com as configurações que desejar, contanto que ela seja MultiLine. (Vide Figura 2)
Figura 2
3. Clique no ícone do CommonDialog que encontra-se na ToolBox (Geralmente canto esquerdo.). E coloque-a sobre a caixa de texto que já se encontra no form e nas propriedades da mesma, altere o campo Filter, colocando 'Arquivo de Texto' e em InitDir; 'C:\'.
Muito bem, form 'desenhado', vamos ao código do programa.
Dê dois cliques sobre o botão que você escolheu para Abrir seus arquivos. E no evento de click desse botão iremos adicionar o seguinte código:
Muito bem, o que ele faz? Ele executa uma função da CommonDialog que busca um arquivo de texto e coloca-o em estado de Input (Insersão de dados) como arquivo primário (Primeiro da lista). E cada linha é inserida após a anterior graças ao loop.
Não vou explicar linha a linha aqui, mais dúvidas postem que eu as respondo.
Certo, os nomes dos campos eu não alterei, logo, revise o código e tenha certeza de que todos os campos estão com os mesmos nomes citados no código.
Agora, no botão designado para salvar arquivos, no evento de click, coloque o seguinte código:
Bom, o que ele faz deve tar na cara né? x]
Sim, ele abre a dialog de confirmação pra salvar arquivos com a terminação '.txt'. O Output é exatamente o oposto de Input, Input = Insersão ou Entrada de dados. Output = Saída de dados.
Espero que tenha sido útil.
Com base nisso ae, vocês podem procurar mais ajuda na web e aperfeiçoar o code e muitas outras coisas
Dúvidas postem ae. ;]
Editado Junho 3 por L0ky