Uriahs
Uriahs
Reputation Top 5%
Uriahs victor
7 Snippets  (114th place)
Published
1 Channel
Created
3 Channels
Following
Sep 29, 2015
Last Visit
May 22, 2015
Registered
171 points  (148th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Trend Maker
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Senior Autobiographer
Serious Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by Uriahs

public by Uriahs created Aug 30, 2015  1859  0  5  0

Simple MySQL database connection with select statement

This snippet has coode to pull the rows from the db in a while loop.
  'Import this to the very top of your code, make sure you have the mysql connector installed for VS
  
  Imports mysql.data.mysqlclient
  
  Dim conn As New MySqlConnection
        Dim cmd As New MySqlCommand
        Dim read As MySqlDataReader



        Try
			'default root would have no pw...simply remove the password part if you have no pw
            conn.ConnectionString = "server=127.0.0.1;user id=root; password=yourpw; database=mydb"


            cmd.Connection = conn


            conn.Open()
            cmd.CommandText = "SELECT id, name FROM mydb.table"
            read = cmd.ExecuteReader

            If read.HasRows Then

                While read.Read
					'name this variable anything you want
                    Dim id = read.GetInt32("id")
                    
                    'for getting a string value:
                    Dim sName = read.GetString("name")
					
					'make the pvname and pvid public(global) variables so you could use them outside while loop,
					'this might not be needed in some cases
		
                    pvname = sName 
                    pvid = id
                End While

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        
        
;

public by Uriahs created Jul 1, 2015  2124  1  6  0

Change default VS webbrowser render engine

Perfect for websites sending out js errors !
create a form called Form1 or just name accordingly, delete everything with its code and paste with below, now you will be surfing using the current installed IE   

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CreateBrowserKey()
       
'Below code adds a custom useragent, adding a custom useragent does not change the actual engine...thats why we need to do all this coding.
WebBrowser1.Navigate("http://www.whatsmybrowser.org", "_top", Nothing, "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36")

'This goes to the website using default user agent.
   'WebBrowser1.Navigate("http://www.whatsmybrowser.org")

    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
        RemoveBrowerKey()
    End Sub
    Private Const BrowserKeyPath As String = "\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
    Private Sub CreateBrowserKey(Optional ByVal IgnoreIDocDirective As Boolean = False)
        Dim basekey As String = Microsoft.Win32.Registry.CurrentUser.ToString
        Dim value As Int32
        Dim thisAppsName As String = My.Application.Info.AssemblyName & ".exe"
        ' Value reference: http://msdn.microsoft.com/en-us/library/ee330730%28v=VS.85%29.aspx
        ' IDOC Reference:  http://msdn.microsoft.com/en-us/library/ms535242%28v=vs.85%29.aspx
        Select Case (New WebBrowser).Version.Major
            Case 8
                If IgnoreIDocDirective Then
                    value = 8888
                Else
                    value = 8000
                End If
            Case 9
                If IgnoreIDocDirective Then
                    value = 9999
                Else
                    value = 9000
                End If
            Case 10
                If IgnoreIDocDirective Then
                    value = 10001
                Else
                    value = 10000
                End If

            Case 11
                If IgnoreIDocDirective Then
                    value = 11001
                Else
                    value = 11000
                End If
            Case Else
                Exit Sub
        End Select
        Microsoft.Win32.Registry.SetValue(Microsoft.Win32.Registry.CurrentUser.ToString & BrowserKeyPath, _
                                          Process.GetCurrentProcess.ProcessName & ".exe", _
                                          value, _
                                          Microsoft.Win32.RegistryValueKind.DWord)
    End Sub
    Private Sub RemoveBrowerKey()
        Dim key As Microsoft.Win32.RegistryKey
        key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(BrowserKeyPath.Substring(1), True)
        key.DeleteValue(Process.GetCurrentProcess.ProcessName & ".exe", False)
    End Sub

End Class
;

public by Uriahs created Jun 29, 2015  310202  1  6  0

Move borderless form VB.NET

Code to move a borderless winform which is not moveable by default
Dim drag As Boolean
   Dim mousex As Integer
   Dim mousey As Integer
   Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
       drag = True 'Sets the variable drag to true.
       mousex = Windows.Forms.Cursor.Position.X - Me.Left 'Sets variable mousex
       mousey = Windows.Forms.Cursor.Position.Y - Me.Top 'Sets variable mousey
   End Sub

   Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
       'If drag is set to true then move the form accordingly.
       If drag Then
           Me.Top = Windows.Forms.Cursor.Position.Y - mousey
           Me.Left = Windows.Forms.Cursor.Position.X - mousex
       End If
   End Sub

   Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
       drag = False 'Sets drag to false, so the form does not move according to the code in MouseMove
   End Sub
;

public by Uriahs created Jun 18, 2015  1972  0  5  0

Prevent more than 1 instance of vb app from opening

From http://stackoverflow.com/questions/1328792/make-single-instance-application-what-does-this-do: mutex
Public Class Form1
Private objMutex As System.Threading.Mutex
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'Check to prevent running twice
    objMutex = New System.Threading.Mutex(False, "MyApplicationName")
    If objMutex.WaitOne(0, False) = False Then
        objMutex.Close()
        objMutex = Nothing
        MessageBox.Show("Another instance is already running!")
        End
    End If
    'If you get to this point it's frist instance

End Sub
End Class

            
;

public by gabriel-shanahan created Jun 18, 2015  2232  0  4  0

CSS libraries and guides to bring some order to the chaos.

CSS libraries and guides to bring some order to the chaos.: css_resources.md
## Libraries
- [960 Grid System](http://960.gs/) - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
- [Compass](http://compass-style.org/) - Open source CSS Authoring Framework.
- [Bootstrap](http://getbootstrap.com/) - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
- [Font Awesome](http://fortawesome.github.io/Font-Awesome/) - The iconic font designed for Bootstrap.
- [Zurb Foundation](http://foundation.zurb.com/) - Framework for writing responsive web sites.
- [SASS](http://sass-lang.com/) - CSS extension language which allows variables, mixins and rules nesting.
- [Skeleton](http://www.getskeleton.com/) - Boilerplate for responsive, mobile-friendly development.

## Guides
- [Scalable and Modular Architecture for CSS](http://smacss.com/) - Learn how to structure your CSS to allow for flexibility and maintainability as your project and your team grows.
- [CSS Property Index](http://www.blooberry.com/indexdot/css/propindex/all.htm) - All properties in an easy-to-digest form.

;