Tips & Tricks for Translation Required

I have a ComboBox2.Text that it has Two Items of name 1 and 2

and i have a file of this type:


Translation For My Tool
[INFO]
Language: Italiano
Author: flash.tato

[1]
FileType: .mox
Object1: Maxtor

[2]
FileType: .sek
Object1: N/A

I want that if ComboBox1.Text is 1 the Label1.Text is .mox and if the ComboBox2.Text is 2 the Label2.Text is .sek

There is a good way

Maybe that it is using ReadLine but how do i move the pointer in a line

From 1st Line to 4st line how do i move



Answer this question

Tips & Tricks for Translation Required

  • CarlosSantamaria

    Thanks

    But if i have string Values as FileX or FileY how do i do


  • Thomas.Goddard

    You'll have to parse the text file somehow and create some kind of collection of ID values and file types. There are a number of ways to accomplish this. Here is one example:


    Dim FileTypeList As New Dictionary(Of Integer, String)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim rdr As New System.IO.StreamReader("c:\temp\filetypes.txt")
    While Not rdr.EndOfStream
    Dim str As String = rdr.ReadLine
    If str.StartsWith("[") Then
    Dim i As Integer
    If Integer.TryParse(str.Replace("[", "").Replace("]", ""), i) Then
    str = rdr.ReadLine
    Dim vals() As String = str.Split(":")
    Me.FileTypeList.Add(i, vals(1).Trim)
    End If
    End If
    End While
    rdr.Close()

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    If Me.ComboBox1.SelectedIndex > -1 Then
    Dim i As Integer
    If Integer.TryParse(Me.ComboBox1.Text, i) Then
    If Me.FileTypeList.ContainsKey(i) Then
    Me.Label1.Text = Me.FileTypeList.Item(i)
    End If
    End If
    End If
    End Sub

    Hope that helps.



  • .NETPhreak

    I don't understand the question. You must explain yourself better...

  • Tips & Tricks for Translation Required