programadorvb6 0 Posted April 2, 2011 Report Share Posted April 2, 2011 Olá boa noite. Tenho um ficheiro com 17 links introduzidos em um ficheiro : Links.txt Quando tento escolher na Combobox um item (Tópico), o mesmo tem que indicar o Link pertencente através da função : Escolher_Link. O problema é que não consigo fazer com que seja lido o ultimo link. Têm alguma ideia do que possa ser?. Grato desde já pela vossa atenção. Atenciosamente. Programadorvb6 ''' <remarks></remarks> ''' <summary> ''' Função para ler determinada linha expecificada pelo programador, em um ficheiro de texto. ''' </summary> ''' <param name="Ficheiro">Leitura de um ficheiro no furmulário</param> ''' <param name="LinhaNumero">Leitura em uma determinada linha em um ficheiro de texto</param> ''' <returns></returns> Public Shared Function Ler_LinhaFicheiro(Ficheiro As String, LinhaNumero As Integer) As String Dim Conteudo As String = String.Empty Try Using Apontador As New StreamReader(Ficheiro) Conteudo = Apontador.ReadToEnd().Replace(vbCr & vbLf, vbLf).Replace(vbLf & vbCr, vbLf) Dim Matriz As String() = Conteudo.Split(New Char() {ControlChars.Lf}) If Matriz.Length > 1 Then If Not LinhaNumero > Matriz.Length AndAlso Not LinhaNumero < 0 Then Return Matriz(LinhaNumero) Else Return Matriz(0) End If Else Return Conteudo End If End Using Catch ex As Exception Return ex.ToString() End Try End Function ''' <summary> ''' Função para indicar onde se encontra a aplicação do utilizador ''' </summary> ''' <remarks></remarks> Public Function GetAppPath() As String Dim i As Integer Dim strAppPath As String strAppPath = System.Reflection.Assembly.GetExecutingAssembly.Location() i = strAppPath.Length - 1 Do Until strAppPath.Substring(i, 1) = "\" i = i - 1 Loop strAppPath = strAppPath.Substring(0, i) Return strAppPath End Function ''' <summary> ''' Escolhe Link mediante a indicação da ComboBox : Links ''' </summary> ''' <remarks></remarks> Public Function Escolher_Link(ByVal IndicarNumero As Double) As String Select Case IndicarNumero Case -1 'Retirei o "IndicaNumero =" pois já está declarado na linha de cima: "Select Case IndicarNumero" Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 0 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 1 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 2 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 3 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 4 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 5 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 6 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 7 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 8 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 9 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 10 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 11 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 12 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 13 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 14 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 15 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case 16 Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) Case Else Escolher_Link = Ler_LinhaFicheiro(GetAppPath() & "\Links.txt", IndicarNumero) MsgBox(Escolher_Link) End Select End Function ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé. Link to post Share on other sites
jpaulino 90 Posted April 8, 2011 Report Share Posted April 8, 2011 Olá, Não entendo muito vem o que queres, nem porque tens um Select Case com tudo igual. Link to post Share on other sites
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