Snippets Vault

Posts 106–113 of 113 · Page 8 of 8
Quote Originally Posted by stokerbandit View Post
Hello, here is the code for a simple Text-To-Speech program.

This should be added to a button and reads the text that is wrote in the "textbox1"

Code:
        Dim SAPI
        SAPI = CreateObject("sapi.spvoice")
        SAPI.Speak(TextBox1.Text)
There (: Enjoy!


Please follow me on twitter for more! ->

If you want me to make a tutorial just make a comment
Moved to the correct place.
Show available diskspace and fullsize
Code:
        
        Dim fullsize As Long
        fullsize = My.Computer.FileSystem.GetDriveInfo("C:\").TotalSize / 1024 / 1024 / 1024 '= Size in GB
        'Divide by 1024 once for KB, twice for MB and three times for GB

        Dim spaceleft As Long
        spaceleft = My.Computer.FileSystem.GetDriveInfo("C:\").AvailableFreeSpace / 1024 / 1024 / 1024 '= Size in GB
        Label1.Text = "C:\ has " & spaceleft & " GB out of " & fullsize & " GB available"

    End Sub
Convert BBCode to HTML code
Code:
Public Function BBCode(ByVal strTextToReplace As String) As String


        '//Define regex
        Dim regExp As Regex


        '//Regex for URL tag without anchor
        regExp = New Regex("\[url\]([^\]]+)\[\/url\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<a href=""$1"">$1</a>")


        '//Regex for URL with anchor
        regExp = New Regex("\[url=([^\]]+)\]([^\]]+)\[\/url\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<a href=""$1"">$2</a>")


        '//Image regex
        regExp = New Regex("\[img\]([^\]]+)\[\/img\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<img src=""$1"" />")


        '//Bold text
        regExp = New Regex("\[b\](.+?)\[\/b\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<b>$1</b>")


        '//Italic text
        regExp = New Regex("\[i\](.+?)\[\/i\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<i>$1</i>")


        '//Underline text
        regExp = New Regex("\[u\](.+?)\[\/u\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<u>$1</u>")


        '//Font size
        regExp = New Regex("\[size=([^\]]+)\]([^\]]+)\[\/size\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<span style=""font-size: $1"">$2</span>")


        '//Font color
        regExp = New Regex("\[color=([^\]]+)\]([^\]]+)\[\/color\]")
        strTextToReplace = regExp.Replace(strTextToReplace, "<span style=""color: $1"">$2</span>")


        Return strTextToReplace
    End Function
Credits to owner
Just wanted to say that this is an excellent resource. -thanks-
nice codes, it will help alot of people
Bookmarking
Bookmarking this page these are very helpful.
Was just about to make a program n found a snippet on here that would help
VB .Net read xml file
how to read xml file in VB .Net
code
Code:
Dim readXML As XmlReader = XmlReader.Create(New StringReader(xmlNode))
While readXML.Read()
    Select Case readXML.NodeType
        Case XmlNodeType.Element
            ListBox1.Items.Add("<" + readXML.Name & ">")
            Exit Select
        Case XmlNodeType.Text
            ListBox1.Items.Add(readXML.Value)
            Exit Select
        Case XmlNodeType.EndElement
            ListBox1.Items.Add("")
            Exit Select
    End Select
End While
from vb.net-informations
compare 2 strings in VB .Net
how to compare 2 strings in in VB .Net simple code

code:
Code:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
        Dim str1 As String
        Dim str2 As String

        str1 = "vb.net"
        str2 = "VB.NET"

        Dim result As Integer

        result = String.Compare(str1, str2)
        MsgBox(result)

        result = String.Compare(str1, str2, True) 'true is case insensitive
        MsgBox(result)
    End Sub
End Class
result is Integer : returns less than zero, zero or greater than zero.
Less than zero : str1 is less than str2.
Zero : str1 is equal to str2.
Greater than zero : str1 is grater than str2.

When you run this program first you get -1 in message box and then 0
Posts 106–113 of 113 · Page 8 of 8

Post a Reply

Talk with us