1,105,578 Community Members

Making own Save type dialog

Member Avatar
VB 2012
Junior Poster
172 posts since Jul 2010
Reputation Points: 4 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 
myCoolFile = chosefolder.SelectedPath & "\" & NameofUal.Text & ".Ual"
          Try
        Dim myCoolWriter As New IO.StreamWriter(myCoolFile, False , [U][I][B]????[/B][/I][/U]) <-<-<-
        For i As Integer = 0 To Mainfrm.ShellProgramslis.Items.Count - 1
            myCoolWriter.WriteLine(Mainfrm.ShellProgramslis.Items(i).ToString & "~" & Mainfrm.myArrayList(i))
        Next
        myCoolWriter.Close()
           Catch Erroronwrite As Exception
          End Try

Ive got some problems how do i say that
thee encoding should look under my combobox of witch one to use(the item that has been chosen):-/

Unhnd_Exception
Deleted Member
 
0
 

One thing you could do is fill the combobox with all the system.Text.EncodingInfo's and set the combobox's DisplayMember to "DisplayName" and the use the System.Text.Encodings.GetEncoding(Ctype(combox.selecteditem,System.text.EnodingInfo).CodePage) to get the encoding.

An easier way is to make a function to return the encoding based on the combobox's string selected item.

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       
        Dim FilePath As String = "C:\No.txt"
        Dim FileStreamWriter As New System.IO.StreamWriter(FilePath, False, GetEncoding)

    End Sub

    Private Function GetEncoding() As System.Text.Encoding
        If ComboBoxEncoding.SelectedIndex = -1 Then
            Throw New IndexOutOfRangeException()
        End If

        Select Case CStr(ComboBoxEncoding.SelectedItem)
            Case "ASCII"
                Return System.Text.Encoding.ASCII
            Case Else
                Return System.Text.Encoding.Default
        End Select

    End Function
Member Avatar
VB 2012
Junior Poster
172 posts since Jul 2010
Reputation Points: 4 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks man that worked

Question Answered as of 3 Years Ago by Unhnd_Exception
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: