none
Como faço uma rotina para carregar arquivos usando OpenToolStreepButton mas... RRS feed

  • Pergunta

  •  

    Olá, estou usando o OpenToolStripButton_Click_1 num Forms para abrir um arquivo txt cujo nome coloco num TextBox, funcionando normal.

    Quero mudar essa rotina para uma que ao clicar no ícone do  OpenToolStripButton_Click_1 apareçam suspensos os vários nomes dos arquivos de uma determinada pasta. Pergunto, é possível fazer isso usando  

    OpenToolStripButton_Click_1 ou tenho que mudar para outro tipo de controle?

    Se for possível, alguém poderia me postar uma rotina que faz isso?

    Grato, Durval.


    quarta-feira, 3 de abril de 2019 22:13

Todas as Respostas

  • Olá, Durval!

    Acredito que o ToolStripDropDownButton é o que precisa!

    https://docs.microsoft.com/pt-br/dotnet/api/system.windows.forms.toolstripdropdown?view=netframework-4.7.2

    https://stackoverflow.com/questions/44038815/how-to-create-a-toolstripdropdownbutton


    “First do it, then do it right, then do it better.” - Addy Osmani

    quinta-feira, 4 de abril de 2019 12:46
  • Valeu, obrigado Wallace, continuo buscando solução. Acredito que não seja tão complicado pois quase todos os menus funcionam da forma que pretendo fazer. Clica no menu pai e uma série de sub menus ficam suspensos, seria isso que pretendo.

    Grato/Durval

    quinta-feira, 4 de abril de 2019 18:09
  • Coloque seu código para analisarmos, assim a gente pode ajudar mais!

    “First do it, then do it right, then do it better.” - Addy Osmani

    quinta-feira, 4 de abril de 2019 19:49
  • Addy, estou tentando fazer essa rotina, porém ainda não tem nada nela que se refira a questão do menu que quero introduzir nessa rotina.

    Imagino o usuário clicando no ícone do menu strip e as opções baixam de forma suspensa com os meses anteriores que já foram salvos no arquivo TXT. Tipo assim:

    (menu)

    pirâmide_janeiro2019

    pirâmide_fevereiro2019

    pirâmide_marco2019

    Ai o usuário pretende abrir o arquivo de fevereiro por exemplo, só clica no pirâmide_fevereiro2019 e o arquivo abre.

    Imports System.IO
    Imports System
    Imports System.Text
    Imports System.Drawing
    Imports System.Collections.Generic
    Imports System.IO.File

    Public Class Form1

        'Dim numPart As Integer
        'Dim W As IO.StreamWriter
        ''rotina que monta a pirâmide limpa, sem os nomes
        'Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '    Dim numRank = New Label() {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8, Label9, Label10, Label11, Label12, Label13, Label14, Label15, Label16, Label17, Label18, Label19, Label20, Label21, Label22, Label23, Label24, Label25, Label26, Label27, Label28, Label29, Label30, Label31, Label32, Label33, Label34, Label35, Label36, Label37, Label38, Label39, Label40, Label41, Label42, Label43, Label44, Label45, Label46, Label47, Label48, Label49, Label50, Label51, Label52, Label53, Label54, Label55, Label56, Label57, Label58, Label59, Label60, Label61, Label62, Label63, Label64, Label65, Label66, Label67, Label68, Label69, Label70, Label71, Label72, Label73, Label74, Label75, Label76, Label77, Label78, Label79, Label80, Label81, Label82, Label83, Label84, Label85, Label86, Label87, Label88, Label89, Label90, Label91, Label92, Label93, Label94, Label95, Label96, Label97, Label98, Label99, Label100, Label101, Label102, Label103, Label104, Label105}
        '    Dim nomesRank = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27, TextBox28, TextBox29, TextBox30, TextBox31, TextBox32, TextBox33, TextBox34, TextBox35, TextBox36, TextBox37, TextBox38, TextBox39, TextBox40, TextBox41, TextBox42, TextBox43, TextBox44, TextBox45, TextBox46, TextBox47, TextBox48, TextBox49, TextBox50, TextBox51, TextBox52, TextBox53, TextBox54, TextBox55, TextBox56, TextBox57, TextBox58, TextBox59, TextBox60, TextBox61, TextBox62, TextBox63, TextBox64, TextBox65, TextBox66, TextBox67, TextBox68, TextBox69, TextBox70, TextBox71, TextBox72, TextBox73, TextBox74, TextBox75, TextBox76, TextBox77, TextBox78, TextBox79, TextBox80, TextBox81, TextBox82, TextBox83, TextBox84, TextBox85, TextBox86, TextBox87, TextBox88, TextBox89, TextBox90, TextBox91, TextBox92, TextBox93, TextBox94, TextBox95, TextBox96, TextBox97, TextBox98, TextBox99, TextBox100, TextBox101, TextBox102, TextBox103, TextBox104, TextBox105}
        '    If TextBox115.Text = "" Then
        '        MsgBox("Entre com o número de tenistas!!!")
        '        Exit Sub
        '    End If
        '    numPart = TextBox115.Text
        '    For u = 0 To 104
        '        numRank(u).Visible = False
        '        nomesRank(u).Visible = False
        '    Next
        '    For n = 0 To (numPart - 1)
        '        numRank(n).Visible = True
        '        nomesRank(n).Visible = True
        '        nomesRank(n).Text = ""
        '    Next
        '    'Label106.Visible = False
        '    'Button1.Visible = False
        '    'TextBox115.Visible = False
        'End Sub
        'salva o aplicativo
        'Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
        '    Dim nomesRank = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27, TextBox28, TextBox29, TextBox30, TextBox31, TextBox32, TextBox33, TextBox34, TextBox35, TextBox36, TextBox37, TextBox38, TextBox39, TextBox40, TextBox41, TextBox42, TextBox43, TextBox44, TextBox45, TextBox46, TextBox47, TextBox48, TextBox49, TextBox50, TextBox51, TextBox52, TextBox53, TextBox54, TextBox55, TextBox56, TextBox57, TextBox58, TextBox59, TextBox60, TextBox61, TextBox62, TextBox63, TextBox64, TextBox65, TextBox66, TextBox67, TextBox68, TextBox69, TextBox70, TextBox71, TextBox72, TextBox73, TextBox74, TextBox75, TextBox76, TextBox77, TextBox78, TextBox79, TextBox80, TextBox81, TextBox82, TextBox83, TextBox84, TextBox85, TextBox86, TextBox87, TextBox88, TextBox89, TextBox90, TextBox91, TextBox92, TextBox93, TextBox94, TextBox95, TextBox96, TextBox97, TextBox98, TextBox99, TextBox100, TextBox101, TextBox102, TextBox103, TextBox104, TextBox105}
        '    Dim numRank = New Label() {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8, Label9, Label10, Label11, Label12, Label13, Label14, Label15, Label16, Label17, Label18, Label19, Label20, Label21, Label22, Label23, Label24, Label25, Label26, Label27, Label28, Label29, Label30, Label31, Label32, Label33, Label34, Label35, Label36, Label37, Label38, Label39, Label40, Label41, Label42, Label43, Label44, Label45, Label46, Label47, Label48, Label49, Label50, Label51, Label52, Label53, Label54, Label55, Label56, Label57, Label58, Label59, Label60, Label61, Label62, Label63, Label64, Label65, Label66, Label67, Label68, Label69, Label70, Label71, Label72, Label73, Label74, Label75, Label76, Label77, Label78, Label79, Label80, Label81, Label82, Label83, Label84, Label85, Label86, Label87, Label88, Label89, Label90, Label91, Label92, Label93, Label94, Label95, Label96, Label97, Label98, Label99, Label100, Label101, Label102, Label103, Label104, Label105}
        '    'Dim nome As String
        '    If TextBox130.Text = "" Then
        '        MsgBox("Entre com o nome da pirâmide (exemplo: marco2019) ")
        '        Exit Sub
        '    End If
        '    'nome = TextBox130.Text
        '    'pergunta se existe o diretório C:\Usuarios\Home se não existe,cria-o
        '    If IO.Directory.Exists("C:\Usuario\Home") = False Then IO.Directory.CreateDirectory("C:\Usuario\Home")
        '    'pergunta se já existe o arquivo "C:\Usuarios\Home" & nome & ".txt","") se não existe, cria-o
        '    'If IO.File.Exists("C:\Usuario\Home\piramide_" & nome) = False Then File.AppendAllText("C:\Usuario\Home\piramide_" & nome & ".txt", "")
        '    If IO.File.Exists("C:\Usuario\Home\piramide.txt") = False Then File.AppendAllText("C:\Usuario\Home\piramide.txt", "")

        '    'atribui o nome do caminho a letra W
        '    'W = New IO.StreamWriter("C:\Usuario\Home\piramide_" & nome & ".txt")
        '    W = New IO.StreamWriter("C:\Usuario\Home\piramide.txt")
        '    'salva o número de partipantes
        '    W.WriteLine(numPart)
        '    'salva os nomes dos tenistas
        '    For u = 0 To (numPart - 1)
        '        W.WriteLine(nomesRank(u).Text)
        '    Next
        '    'salva os números do Rank
        '    For u = 0 To (numPart - 1)
        '        W.WriteLine(numRank(u).Text)
        '    Next
        '    W.Close()
        '    'aciona o timer e avisa que foi salvo com sucesso
        '    Label110.Visible = True 'label110="Salvo com sucesso!!!"
        '    Timer1.Interval = 1000 'intervalo de 1 segundo
        '    Timer1.Start() 'dispara o timer
        'End Sub
        'encerra o timer em 1 segundo
        'Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        '    Timer1.Stop()
        '    Label110.Visible = False 'label110="Salvo com sucesso!!!"
        'End Sub
        'carrega baseado no nome do arquivo no Bloco de Notas
        'Private Sub OpenToolStripButton_Click_1(sender As Object, e As EventArgs) Handles OpenToolStripButton.Click
        '    Dim nomesRank = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27, TextBox28, TextBox29, TextBox30, TextBox31, TextBox32, TextBox33, TextBox34, TextBox35, TextBox36, TextBox37, TextBox38, TextBox39, TextBox40, TextBox41, TextBox42, TextBox43, TextBox44, TextBox45, TextBox46, TextBox47, TextBox48, TextBox49, TextBox50, TextBox51, TextBox52, TextBox53, TextBox54, TextBox55, TextBox56, TextBox57, TextBox58, TextBox59, TextBox60, TextBox61, TextBox62, TextBox63, TextBox64, TextBox65, TextBox66, TextBox67, TextBox68, TextBox69, TextBox70, TextBox71, TextBox72, TextBox73, TextBox74, TextBox75, TextBox76, TextBox77, TextBox78, TextBox79, TextBox80, TextBox81, TextBox82, TextBox83, TextBox84, TextBox85, TextBox86, TextBox87, TextBox88, TextBox89, TextBox90, TextBox91, TextBox92, TextBox93, TextBox94, TextBox95, TextBox96, TextBox97, TextBox98, TextBox99, TextBox100, TextBox101, TextBox102, TextBox103, TextBox104, TextBox105}
        '    Dim numRank = New Label() {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8, Label9, Label10, Label11, Label12, Label13, Label14, Label15, Label16, Label17, Label18, Label19, Label20, Label21, Label22, Label23, Label24, Label25, Label26, Label27, Label28, Label29, Label30, Label31, Label32, Label33, Label34, Label35, Label36, Label37, Label38, Label39, Label40, Label41, Label42, Label43, Label44, Label45, Label46, Label47, Label48, Label49, Label50, Label51, Label52, Label53, Label54, Label55, Label56, Label57, Label58, Label59, Label60, Label61, Label62, Label63, Label64, Label65, Label66, Label67, Label68, Label69, Label70, Label71, Label72, Label73, Label74, Label75, Label76, Label77, Label78, Label79, Label80, Label81, Label82, Label83, Label84, Label85, Label86, Label87, Label88, Label89, Label90, Label91, Label92, Label93, Label94, Label95, Label96, Label97, Label98, Label99, Label100, Label101, Label102, Label103, Label104, Label105}
        '    Dim R As IO.StreamReader
        '    Dim nome As String
        '    If TextBox130.Text = "" Then
        '        MsgBox("Preencha o nome da pirâmide. (exemplo: abril2019)")
        '        Exit Sub
        '    End If
        '    nome = TextBox130.Text
        '    'pergunta se existe o diretório C:\Usuarios\Home se não existe,cria
        '    If IO.Directory.Exists("C:\Usuario\Home") = False Then IO.Directory.CreateDirectory("C:\Usuario\Home" & ".txt")
        '    'pergunta se já existe o arquivo "C:\Usuarios\Home\piramide_" & nome & "txt" se não existe, cria
        '    'If IO.File.Exists("C:\Usuario\Home\piramide_" & nome & ".txt") = False Then File.AppendAllText("C:\Usuario\Home\piramide_" & nome & ".txt", "")
        '    If IO.File.Exists("C:\Usuario\Home\piramide.txt") = False Then File.AppendAllText("C:\Usuario\Home\piramide.txt", "")

        '    'R = New IO.StreamReader("C:\Usuario\Home\piramide_" & nome & ".txt")
        '    R = New IO.StreamReader("C:\Usuario\Home\piramide.txt")
        '    numPart = R.ReadLine
        '    For u = 0 To 104
        '        numRank(u).Visible = False
        '        nomesRank(u).Visible = False
        '    Next
        '    For n = 0 To (numPart - 1)
        '        numRank(n).Visible = True
        '        nomesRank(n).Visible = True
        '    Next
        '    'carrega os nomes dos tenistas
        '    For u = 0 To (numPart - 1)
        '        nomesRank(u).Text = R.ReadLine
        '    Next
        '    'carrega os números do Rank
        '    For u = 0 To (numPart - 1)
        '        numRank(u).Text = R.ReadLine
        '    Next
        '    R.Close()
        'End Sub
        'função que auto-completa os nomes dos tenistas
        Private Diretorio As String = "C:\Usuario\Home"
        Private Caminho As String = "C:\Usuario\Home\piramide.txt"
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'Carrega_lista()
            Carrega_piramide()
        End Sub
        Private Sub TextBox_Leave(sender As Object, e As EventArgs) Handles TextBox1.Leave, TextBox2.Leave, TextBox3.Leave, TextBox4.Leave, TextBox5.Leave, TextBox6.Leave, TextBox7.Leave, TextBox8.Leave, TextBox9.Leave, TextBox10.Leave, TextBox11.Leave, TextBox12.Leave, TextBox13.Leave, TextBox14.Leave, TextBox15.Leave, TextBox16.Leave, TextBox17.Leave, TextBox18.Leave, TextBox19.Leave, TextBox20.Leave, TextBox21.Leave, TextBox22.Leave, TextBox23.Leave, TextBox24.Leave, TextBox25.Leave, TextBox26.Leave, TextBox27.Leave, TextBox28.Leave, TextBox29.Leave, TextBox30.Leave, TextBox31.Leave, TextBox32.Leave, TextBox33.Leave, TextBox34.Leave, TextBox35.Leave, TextBox36.Leave, TextBox37.Leave, TextBox38.Leave, TextBox39.Leave, TextBox40.Leave, TextBox41.Leave, TextBox42.Leave, TextBox43.Leave, TextBox44.Leave, TextBox45.Leave, TextBox46.Leave, TextBox47.Leave, TextBox48.Leave, TextBox49.Leave, TextBox50.Leave, TextBox51.Leave, TextBox52.Leave, TextBox53.Leave, TextBox54.Leave, TextBox55.Leave, TextBox56.Leave, TextBox57.Leave, TextBox58.Leave, TextBox59.Leave, TextBox60.Leave, TextBox61.Leave, TextBox62.Leave, TextBox63.Leave, TextBox64.Leave, TextBox65.Leave, TextBox66.Leave, TextBox67.Leave, TextBox68.Leave, TextBox69.Leave, TextBox70.Leave, TextBox71.Leave, TextBox72.Leave, TextBox73.Leave, TextBox74.Leave, TextBox75.Leave, TextBox76.Leave, TextBox77.Leave, TextBox78.Leave, TextBox79.Leave, TextBox80.Leave, TextBox81.Leave, TextBox82.Leave, TextBox83.Leave, TextBox84.Leave, TextBox85.Leave, TextBox86.Leave, TextBox87.Leave, TextBox88.Leave, TextBox89.Leave, TextBox90.Leave, TextBox91.Leave, TextBox92.Leave, TextBox93.Leave, TextBox94.Leave, TextBox95.Leave, TextBox96.Leave, TextBox97.Leave, TextBox98.Leave, TextBox99.Leave, TextBox100.Leave, TextBox101.Leave, TextBox102.Leave, TextBox103.Leave, TextBox104.Leave, TextBox105.Leave
            Atualiza_lista(CType(sender, TextBox))
            'Carrega_lista()
            Carrega_piramide()
        End Sub
        'Private Sub Carrega_lista()
        Private Sub Carrega_piramide()
            'Dim lista As New List(Of String)
            Dim piramide As New List(Of String)
            Dim MySource As New AutoCompleteStringCollection()
            Dim nomesRank = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27, TextBox28, TextBox29, TextBox30, TextBox31, TextBox32, TextBox33, TextBox34, TextBox35, TextBox36, TextBox37, TextBox38, TextBox39, TextBox40, TextBox41, TextBox42, TextBox43, TextBox44, TextBox45, TextBox46, TextBox47, TextBox48, TextBox49, TextBox50, TextBox51, TextBox52, TextBox53, TextBox54, TextBox55, TextBox56, TextBox57, TextBox58, TextBox59, TextBox60, TextBox61, TextBox62, TextBox63, TextBox64, TextBox65, TextBox66, TextBox67, TextBox68, TextBox69, TextBox70, TextBox71, TextBox72, TextBox73, TextBox74, TextBox75, TextBox76, TextBox77, TextBox78, TextBox79, TextBox80, TextBox81, TextBox82, TextBox83, TextBox84, TextBox85, TextBox86, TextBox87, TextBox88, TextBox89, TextBox90, TextBox91, TextBox92, TextBox93, TextBox94, TextBox95, TextBox96, TextBox97, TextBox98, TextBox99, TextBox100, TextBox101, TextBox102, TextBox103, TextBox104, TextBox105}
            If IO.Directory.Exists(Diretorio) = False Then IO.Directory.CreateDirectory(Diretorio)
            If IO.File.Exists(Caminho) = False Then File.AppendAllText(Caminho, "")
            Using sr As StreamReader = File.OpenText(Caminho)  'Percorre o arquivo para carregar a lista para o AutoComplete
                Do While sr.Peek() >= 0
                    'lista.Add(sr.ReadLine)
                    piramide.Add(sr.ReadLine)
                Loop
            End Using
            'MySource.AddRange(lista.ToArray)
            MySource.AddRange(piramide.ToArray)
            For n = 0 To 104
                nomesRank(n).AutoCompleteCustomSource = MySource
                nomesRank(n).AutoCompleteMode = AutoCompleteMode.SuggestAppend
                nomesRank(n).AutoCompleteSource = AutoCompleteSource.CustomSource
            Next
        End Sub
        'Private Sub Atualiza_lista(nomesRank As TextBox)
        Private Sub Atualiza_lista(piramide As TextBox)
            Dim lista As New List(Of String)
            Using sr As StreamReader = File.OpenText(Caminho)
                Do While sr.Peek() >= 0
                    lista.Add(sr.ReadLine)
                Loop
            End Using 'carrega a lista atual
            'If lista.IndexOf(nomesRank.Text) = -1 Then 'verifica se a palavra já está na lista.
            If lista.IndexOf(piramide.Text) = -1 Then 'verifica se a palavra já está na lista.
                Using sw As StreamWriter = File.AppendText(Caminho)
                    'sw.WriteLine(nomesRank.Text) 'se não estiver, acrescenta na lista
                    sw.WriteLine(piramide.Text) 'se não estiver, acrescenta na lista
                End Using
            End If
        End Sub
        Private Sub TextBox_MouseDoubleClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDoubleClick, TextBox2.MouseDoubleClick, TextBox3.MouseDoubleClick, TextBox4.MouseDoubleClick, TextBox5.MouseDoubleClick, TextBox6.MouseDoubleClick, TextBox7.MouseDoubleClick, TextBox8.MouseDoubleClick, TextBox9.MouseDoubleClick, TextBox10.MouseDoubleClick, TextBox11.MouseDoubleClick, TextBox12.MouseDoubleClick, TextBox13.MouseDoubleClick, TextBox14.MouseDoubleClick, TextBox15.MouseDoubleClick, TextBox16.MouseDoubleClick, TextBox17.MouseDoubleClick, TextBox18.MouseDoubleClick, TextBox19.MouseDoubleClick, TextBox20.MouseDoubleClick, TextBox21.MouseDoubleClick, TextBox22.MouseDoubleClick, TextBox23.MouseDoubleClick, TextBox24.MouseDoubleClick, TextBox25.MouseDoubleClick, TextBox26.MouseDoubleClick, TextBox27.MouseDoubleClick, TextBox28.MouseDoubleClick, TextBox29.MouseDoubleClick, TextBox30.MouseDoubleClick, TextBox31.MouseDoubleClick, TextBox32.MouseDoubleClick, TextBox33.MouseDoubleClick, TextBox34.MouseDoubleClick, TextBox35.MouseDoubleClick, TextBox36.MouseDoubleClick, TextBox37.MouseDoubleClick, TextBox38.MouseDoubleClick, TextBox39.MouseDoubleClick, TextBox40.MouseDoubleClick, TextBox41.MouseDoubleClick, TextBox42.MouseDoubleClick, TextBox43.MouseDoubleClick, TextBox44.MouseDoubleClick, TextBox45.MouseDoubleClick, TextBox46.MouseDoubleClick, TextBox47.MouseDoubleClick, TextBox48.MouseDoubleClick, TextBox49.MouseDoubleClick, TextBox50.MouseDoubleClick, TextBox51.MouseDoubleClick, TextBox52.MouseDoubleClick, TextBox53.MouseDoubleClick, TextBox54.MouseDoubleClick, TextBox55.MouseDoubleClick, TextBox56.MouseDoubleClick, TextBox57.MouseDoubleClick, TextBox58.MouseDoubleClick, TextBox59.MouseDoubleClick, TextBox60.MouseDoubleClick, TextBox61.MouseDoubleClick, TextBox62.MouseDoubleClick, TextBox63.MouseDoubleClick, TextBox64.MouseDoubleClick, TextBox65.MouseDoubleClick, TextBox66.MouseDoubleClick, TextBox67.MouseDoubleClick, TextBox68.MouseDoubleClick, TextBox69.MouseDoubleClick, TextBox70.MouseDoubleClick, TextBox71.MouseDoubleClick, TextBox72.MouseDoubleClick, TextBox73.MouseDoubleClick, TextBox74.MouseDoubleClick, TextBox75.MouseDoubleClick, TextBox76.MouseDoubleClick, TextBox77.MouseDoubleClick, TextBox78.MouseDoubleClick, TextBox79.MouseDoubleClick, TextBox80.MouseDoubleClick, TextBox81.MouseDoubleClick, TextBox82.MouseDoubleClick, TextBox83.MouseDoubleClick, TextBox84.MouseDoubleClick, TextBox85.MouseDoubleClick, TextBox86.MouseDoubleClick, TextBox87.MouseDoubleClick, TextBox88.MouseDoubleClick, TextBox89.MouseDoubleClick, TextBox90.MouseDoubleClick, TextBox91.MouseDoubleClick, TextBox92.MouseDoubleClick, TextBox93.MouseDoubleClick, TextBox94.MouseDoubleClick, TextBox95.MouseDoubleClick, TextBox96.MouseDoubleClick, TextBox97.MouseDoubleClick, TextBox98.MouseDoubleClick, TextBox99.MouseDoubleClick, TextBox100.MouseDoubleClick, TextBox101.MouseDoubleClick, TextBox102.MouseDoubleClick, TextBox103.MouseDoubleClick, TextBox104.MouseDoubleClick, TextBox105.MouseDoubleClick
            'Remove_lista(CType(sender, TextBox))
            Remove_piramide(CType(sender, TextBox))
        End Sub
        'Private Sub Remove_lista(nomesRank As TextBox)
        'Private Sub Remove_lista(piramide As TextBox)
        Private Sub Remove_piramide(piramide As TextBox)
            Dim J As Int32
            Dim lista As New List(Of String)
            Try
                'Using sr As StreamReader = File.OpenText(Caminho)
                Using sr As StreamReader = File.OpenText("C:\Usuario\Home\piramide.txt")
                    Do While sr.Peek() >= 0
                        lista.Add(sr.ReadLine)
                    Loop
                End Using 'carrego a lista atual
                'lista.Remove(nomesRank.Text)
                lista.Remove(piramide.Text)
                'nomesRank.Text = ""
                piramide.Text = ""
                File.AppendAllText(Caminho & ".tmp", "") 'cria arquivo temporário
                For J = 0 To lista.Count - 1
                    Using sw As StreamWriter = File.AppendText(Caminho & ".tmp")
                        sw.WriteLine(lista.Item(J)) 'acrescenta na lista temporária
                    End Using
                Next
                File.Delete(Caminho) 'deleta a listagem anterior
                File.Move(Caminho & ".tmp", Caminho)
                'Carrega_lista()
                Carrega_piramide()
            Catch ex As Exception
                MsgBox("Erro ao deletar item da listagem.")
            End Try
        End Sub
    End Class
    quinta-feira, 4 de abril de 2019 20:18