We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,745 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Making own Save type dialog

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):-/

2
Contributors
2
Replies
17 Hours
Discussion Span
2 Years Ago
Last Updated
3
Views
Question
Answered
VB 2012
Junior Poster
168 posts since Jul 2010
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 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
Unhnd_Exception
Deleted Member

Thanks man that worked

VB 2012
Junior Poster
168 posts since Jul 2010
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 2 Years Ago by Unhnd_Exception

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0665 seconds using 2.68MB