Click here to Skip to main content
15,887,083 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Get Attributes of External Assemblies Pin
Dominick Marciano12-Sep-14 6:36
professionalDominick Marciano12-Sep-14 6:36 
QuestionSynchronization of camera and shell orientation Windows 8.1 Surface Pin
Member 110572154-Sep-14 3:33
Member 110572154-Sep-14 3:33 
QuestionCopy selected listview item to a textbox VB.NET Pin
Pete_1233-Sep-14 5:49
Pete_1233-Sep-14 5:49 
AnswerRe: Copy selected listview item to a textbox VB.NET Pin
Eddy Vluggen3-Sep-14 7:14
professionalEddy Vluggen3-Sep-14 7:14 
QuestionRe: Copy selected listview item to a textbox VB.NET Pin
Pete_1234-Sep-14 7:01
Pete_1234-Sep-14 7:01 
AnswerRe: Copy selected listview item to a textbox VB.NET Pin
Eddy Vluggen4-Sep-14 8:15
professionalEddy Vluggen4-Sep-14 8:15 
AnswerRe: Copy selected listview item to a textbox VB.NET Pin
Tino Fourie24-Sep-14 6:49
Tino Fourie24-Sep-14 6:49 
Questionstring to byte, having trouble with line feed characters Pin
jkirkerx1-Sep-14 10:15
professionaljkirkerx1-Sep-14 10:15 
I'm just trying to write a HTML text file. I can read text files, but first time writing them.

So I used the StringBuilder to build some HTML
Then I wrote a for loop to convert the stringbuilder to bytes, and then I wrote the BOM and the rest of the HTML as a file using FileStream

So I choose UT8 as the encoding, but I get the error line feed characters are inconsistent in Visual Studio when testing the file.

The original problem is when I write the file the 2nd time, and read it back, I get a BOM error, but I thought perhaps I need to fix the line feed chars first. I'm not really sure what to do here on this.

Dim m_htmlBuilder As New StringBuilder
        With m_htmlBuilder
            .Append("<div style=""width: " & p_width & "; Height: " & p_height & "; text-align: center; margin: 0px auto; background-color: rgb(28,134,238);"">" & vbCrLf)
            .Append("   <span style=""color: rgb(255,255,255); font-size: 1.0em; font-weight: bold; line-height: " & p_height & ";"">" & vbCrLf)
            .Append(p_html_name & " is now ready for use" & vbCrLf)
            .Append("   </span>" & vbCrLf)
            .Append("</div>" & vbCrLf)
        End With

        Dim m_htmlStream As String = m_htmlBuilder.ToString

        Try

            Dim htmlLen As Long = m_htmlStream.Length
            Dim charArray As Char() = New Char(htmlLen) {}
            Dim byteArray() As Byte = New Byte() {}

            For cdx As Integer = 0 To htmlLen - 1
                charArray(cdx) = m_htmlStream(cdx)
                Dim charVal As Char = charArray(cdx)
                Array.Resize(byteArray, byteArray.Length + 1)
                byteArray(byteArray.Length - 1) = UTF8CharToByte(charVal)
            Next

            Using htmlStream = New FileStream(p_html_path, FileMode.Create, FileAccess.Write)
                Using writer As BinaryWriter = New BinaryWriter(htmlStream, Encoding.UTF8)
                    Dim [utf8] As Encoding = Encoding.UTF8
                    Dim preamble As Byte() = [utf8].GetPreamble()
                    writer.Write(preamble)
                    writer.Write(byteArray, 0, byteArray.Length - 1)

                    If Not (writer Is Nothing) Then
                        writer.Close()
                        writer.Dispose()
                    End If

                End Using

                If Not (htmlStream Is Nothing) Then
                    htmlStream.Close()
                    htmlStream.Dispose()
                End If

            End Using

AnswerRe: string to byte, having trouble with line feed characters Pin
Dave Kreskowiak1-Sep-14 11:19
mveDave Kreskowiak1-Sep-14 11:19 
GeneralRe: string to byte, having trouble with line feed characters Pin
jkirkerx1-Sep-14 12:09
professionaljkirkerx1-Sep-14 12:09 
QuestionHow to use own collections in application settings in VB.NET? Pin
ponchofiesta31-Aug-14 21:35
ponchofiesta31-Aug-14 21:35 
AnswerRe: How to use own collections in application settings in VB.NET? Pin
Eddy Vluggen1-Sep-14 0:27
professionalEddy Vluggen1-Sep-14 0:27 
Questionwav to mp3 Pin
Ali Asgar29-Aug-14 4:52
Ali Asgar29-Aug-14 4:52 
AnswerRe: wav to mp3 Pin
Dave Kreskowiak29-Aug-14 5:05
mveDave Kreskowiak29-Aug-14 5:05 
GeneralRe: wav to mp3 Pin
Tim Carmichael29-Aug-14 6:28
Tim Carmichael29-Aug-14 6:28 
QuestionRe: wav to mp3 Pin
ZurdoDev29-Aug-14 5:38
professionalZurdoDev29-Aug-14 5:38 
QuestionVB6: error- report writer does not support multidimensional hierarchy Pin
Member 1102617826-Aug-14 3:20
Member 1102617826-Aug-14 3:20 
AnswerRe: VB6: error- report writer does not support multidimensional hierarchy Pin
Chris Quinn26-Aug-14 22:12
Chris Quinn26-Aug-14 22:12 
QuestionMessage Closed Pin
25-Aug-14 1:15
Jashan12325-Aug-14 1:15 
SuggestionRe: Algorithms to Visual Basic Code Pin
Tim Carmichael25-Aug-14 1:58
Tim Carmichael25-Aug-14 1:58 
QuestionRe: Algorithms to Visual Basic Code Pin
ZurdoDev25-Aug-14 2:07
professionalZurdoDev25-Aug-14 2:07 
AnswerRe: Algorithms to Visual Basic Code Pin
Mycroft Holmes25-Aug-14 12:29
professionalMycroft Holmes25-Aug-14 12:29 
GeneralMessage Closed Pin
26-Aug-14 2:52
Jashan12326-Aug-14 2:52 
GeneralRe: Algorithms to Visual Basic Code Pin
Tim Carmichael26-Aug-14 3:05
Tim Carmichael26-Aug-14 3:05 
GeneralMessage Closed Pin
26-Aug-14 3:15
Jashan12326-Aug-14 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.