Click here to Skip to main content
15,892,161 members
Articles / Programming Languages / Visual Basic

A Study of Gage Repeatability and Reproducibility for Automated Measuring Systems using VB.NET

Rate me:
Please Sign up or sign in to vote.
5.00/5 (11 votes)
24 Jan 2015CPOL6 min read 53K   1.3K   5  
Gage R&R using VB.NET.
Imports System.IO
Imports System.Text
Public Class ConnectionClass
    Dim Connection As Odbc.OdbcConnection
    Private config As Configuration.ConfigurationSettings
    'Dim config As Configuration.ConfigurationSettings
    'Author  : Syed Shanu
    'Company : Telstar-Hommel
    'Date    : 2007-06-22
    'Description :This Class is  created for Database Connection Establishment
    Sub New()
        Try
            Dim ConnectionString As String
            dbConChk = False
            'For MySql Connectivity
            'str = "dsn=mysqldsn;user id=root;password=;database=esr;Min Pool Size =1;Max Pool Size=1;Connection Lifetime=1;pooling=true;"
            'For SqlServer Connectivity
            ConnectionString = getConnectionString()
            'ConnectionString = config.AppSettings("ConnectionString")
            'ConnectionString = "Driver={SQL Server};Server=127.0.0.1;Database=ESR;Uid=Sa;Pwd="
            Connection = New Odbc.OdbcConnection(ConnectionString)
            Connection.Open()
            QDasKeyFieldCreation()
        Catch Ex As Exception
            dbConChk = True
            ' MessageBox.Show("server Not Found")
        End Try
    End Sub
    Public Property Conobj() As Odbc.OdbcConnection
        Get
            Return Connection
            'Returns the Opened Connection
        End Get
        Set(ByVal value As Odbc.OdbcConnection)
        End Set
    End Property
    Public Overloads Sub dispose()
        Connection.Close()
        'Closes the Connection
    End Sub
    ' 'Created by shanu on 2007-06-23 to create a connection as a text file if file not there new file created and readed else it will read the connection string from text file
    Public Function getConnectionString() As String
        Try
            Dim ExePath As String
            Dim dbFileName As String
            Dim ioLine As String
            ExePath = Application.StartupPath
            ExePath = ExePath & "\"
            Dim ioFileReader As StreamReader
            Dim ioFileWriter As StreamWriter
            dbFileName = ExePath & "dbConnString.txt"
            If File.Exists(dbFileName) Then
                'File.Delete("TextFile.txt")
                'Created by shanu 2007/06/23 to Read Data
                ioFileReader = New StreamReader(dbFileName)
                ' Going to hold one line at a time
                ioLine = ioFileReader.ReadLine
                ioFileReader.Close()
            Else
                'Created by shanu 2007/06/23 on to create file and write data
                ioFileWriter = New StreamWriter(dbFileName)
                ioFileWriter.WriteLine("Driver={SQL Server};Server=MLAS1\TELSTAR;Database=MLA;Uid=Sa;Pwd=plokijuh;")
                ioFileWriter.Close()
                ioLine = "Driver={SQL Server};Server=MLAS1\TELSTAR;Database=MLA;Uid=Sa;Pwd=plokijuh;"
                '    'Created by shanu 2007/06/23 To Read Data
                ''ioFileReader = New StreamReader(dbFileName)

                ''ioLine = ioFileReader.ReadLine

                ''ioFileReader.Close()
            End If
            Return ioLine
        Catch ex As Exception
        End Try
    End Function
    ' 'Created by shanu on 2007-06-23 to create a connection as a text file if file not there new file created and readed else it will read the connection string from text file
    Public Function QDasKeyFieldCreation() As String
        Try
            Dim ExePath As String
            Dim dbFileName As String
            Dim ioLine As String
            ExePath = Application.StartupPath
            ExePath = ExePath & "\"
            '   Dim ioFileReader As StreamReader
            Dim sw As StreamWriter
            dbFileName = ExePath & "QDasKeyFields.txt"
            If Not File.Exists(dbFileName) Then
             
                sw = New StreamWriter(dbFileName)


                sw.WriteLine("K0100 1")
                sw.WriteLine("K0101 2")
                sw.WriteLine("K1001/1 ") 'For Part No.
                sw.WriteLine("K1002/1 ") 'For Part Description
                sw.WriteLine("K1010/1 0")
                sw.WriteLine("K1015/1 0")
                sw.WriteLine("K1053 60")
                sw.WriteLine("K1300/1 0")
                sw.WriteLine("K1301/1 0")
                sw.WriteLine("K1998/1 0/0/0/0/0/0/0/0/1/1/0/0/0/0/0/0/0/0/0/0/0")
                sw.WriteLine("K2001/1 ") 'Characteristics No.
                sw.WriteLine("K2002/1 ") 'Characteristics Description
                sw.WriteLine("K2004/1 0")
                sw.WriteLine("K2005/1 3")
                sw.WriteLine("K2006/1 0")
                sw.WriteLine("K2007/1 0")
                sw.WriteLine("K2008/1 0")
                sw.WriteLine("K2011/1 1")
                sw.WriteLine("K2013/1 0.000")
                sw.WriteLine("K2015/1 0")
                sw.WriteLine("K2022/1 3")
                sw.WriteLine("K2023/1 0")
                sw.WriteLine("K2024/1 0.000")
                sw.WriteLine("K2025/1 0.000")
                sw.WriteLine("K2026/1 0.000")
                sw.WriteLine("K2027/1 0.000")
                sw.WriteLine("K2028/1 0")
                sw.WriteLine("K2041/1 0")
                sw.WriteLine("K2042/1 0")
                sw.WriteLine("K2044/1 0")
                sw.WriteLine("K2045/1 0")
                sw.WriteLine("K2046/1 0")
                sw.WriteLine("K2047/1 0")
                sw.WriteLine("K2048/1 0")
                sw.WriteLine("K2049/1 0")
                sw.WriteLine("K2051/1 0")
                sw.WriteLine("K2052/1 0")
                sw.WriteLine("K2054/1 0")
                sw.WriteLine("K2055/1 0")
                sw.WriteLine("K2056/1 0")
                sw.WriteLine("K2060/1 0")
                sw.WriteLine("K2061/1 0")
                sw.WriteLine("K2071/1 0.000")
                sw.WriteLine("K2072/1 1.000")
                sw.WriteLine("K2074/1 0.000")
                sw.WriteLine("K2075/1 1.000")
                ' sw.WriteLine("k2101/1 28")
                sw.WriteLine("K2110/1 ") 'For LSL
                sw.WriteLine("K2111/1 ") 'For USL
                sw.WriteLine("K2120/1 1")
                sw.WriteLine("K2121/1 1")
                sw.WriteLine("K2135/1 0.000")
                sw.WriteLine("K2142/1 mm")
                sw.WriteLine("K2144/1 0.000")
                sw.WriteLine("K2145/1 0.000")
                sw.WriteLine("K2146/1 0")
                sw.WriteLine("K2152/1 0.250")
                sw.WriteLine("K2201/1 0")
                sw.WriteLine("K2202/1 1")
                sw.WriteLine("K2203/1 0")
                sw.WriteLine("K2205/1 0")
                sw.WriteLine("K2213/1 ") 'This is the Xm that is nominal Value(Offset)
                sw.WriteLine("K2220/1 1")
                sw.WriteLine("K2221/1 1")
                sw.WriteLine("K2222/1 20")
                sw.WriteLine("K2404/1 0.001")
                sw.WriteLine("K2430/1 0")
                sw.WriteLine("K2432/1 0")
                sw.WriteLine("K2434/1 0")
                sw.WriteLine("K2601/1 2")
                sw.WriteLine("K2610/1 0")
                sw.WriteLine("K2613/1 0.0000000000")
                sw.WriteLine("K2619/1 0")
                sw.WriteLine("K2631/1 2.0000")
                sw.WriteLine("K2700/1 0")
                sw.WriteLine("K2080/1 0")
                sw.Close()
            End If

        Catch ex As Exception
        End Try
    End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
India India
Microsoft MVP | Code Project MVP | CSharp Corner MVP | Author | Blogger and always happy to Share what he knows to others. MyBlog

My Interview on Microsoft TechNet Wiki Ninja Link

Comments and Discussions