Visual Basic (.NET)2011.10.12 15:57


Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Collections
Imports System.Threading
Imports System.Runtime.Interopservices
Imports System.Data.OleDb
Imports Microsoft.VisualBasic


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim OpenFileDlg As New OpenFileDialog()
        OpenFileDlg.Filter = "Excel파일|*.xl*"
        If (OpenFileDlg.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            Dim path As String = OpenFileDlg.FileName
            Dim strArr() As String = path.Split(".")
            If (strArr(strArr.Length - 1) = "xls") Then
                BINDING_EXCEL2003(path)
            Else
                BINDING_EXCEL2007(path)
            End If
        End If
    End Sub
  
    Private Sub BINDING_EXCEL2007(ByVal path)

        Dim connection As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = " + path + ";Extended Properties = Excel 12.0;"
        BINDING(connection)
    End Sub
    Private Sub BINDING_EXCEL2003(ByVal path)
        Dim connection As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " + path + ";Extended Properties = Excel 8.0;"
        BINDING(connection)
    End Sub
    Private Sub BINDING(ByVal strConnection)
        Try
            Dim DBConnection As New OleDbConnection(strConnection)
            Dim sqlQuery As String = "SELECT * FROM [Sheet1$]"
            Dim DBCommand As New OleDbCommand(sqlQuery, DBConnection)
            DBConnection.Open()
            Dim adp As New OleDbDataAdapter()
            adp.SelectCommand = DBCommand
            Dim Rs1 As New DataSet()
            adp.Fill(Rs1)
            DataGridView1.DataSource = Rs1.Tables(0).DefaultView
            DBConnection.Close()
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub
   
    Private Sub DataGridView1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
        Dim path As String = e.Data.GetData(DataFormats.FileDrop)(0).ToString()
        Dim strArr() As String = Path.Split(".")
        If (strArr(strArr.Length - 1) = "xls") Then
            BINDING_EXCEL2003(Path)
        Else
            BINDING_EXCEL2007(Path)
        End If

    End Sub

    Private Sub DataGridView1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
        If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If

    End Sub
End Class

Posted by 민구니

◆ 프로그램에서 단 하나의 인스턴스(Instance)만 존재하게 하고 싶을 때 사용하는 패턴.
   - 어디서든지 그 인스턴스에 접근할 수 있기 때문에 전역 변수 등을 관리할 때 유용.


1번 예제 :  멀티 쓰레드 환경에서 문제가 발생.
 - 멀티 쓰레드(Multi-Thread) 환경에서는 getInstace() 메소드가 끝나기 전에
   각각의 쓰레드에서 접근이 가능하기 때문에 운이 없으면 인스턴스가 여러 개 생성될 수도 있다.
 
01.public class MyClass
02.{
03.    private static MyClass m_MyClass = null;
04.      
05.    private MyClass() {}
06.      
07.    public static MyClass getInstance()
08.    {
09.        if (m_MyClass == null)
10.        {
11.            m_MyClass = new MyClass();
12.        }
13.          
14.        return m_MyClass;
15.    }
16.}



2번 예제 : getInstance() 메소드를 synchronized로 동기화시키는 방법
 - 함수 전체에 synchronized는 동기화 과정에서 속도 문제가 발생

 01.public static synchronized MyClass getInstance()
02.{
03.    if (m_MyClass == null)
04.    {
05.        m_MyClass = new MyClass();
06.    }
07.      
08.    return m_MyClass;
09.}



3번 예제 함수 전체에 synchronized를 거는 것이 아니라 함수 내부의 특정 구간에만 거는 방법.
    -2번 예제의 속도 문제를 개선할 수 있다.

 01.public static MyClass getInstance()
02.{
03.    if (m_MyClass == null)
04.    {
05.        synchronized(MyClass.class)
06.        {
07.            if (m_MyClass == null)
08.            {
09.                m_MyClass = new MyClass();
10.            }
11.        }
12.    }
13.      
14.    return m_MyClass;
15.}


4번 예제 :
처음부터 인스턴스를 생성해버리는 방법.
 -  이 경우는 프로그램이 처음 실행되면서 바로 인스턴스가 생겨버리기 때문에 불필요한 부분에서 인스턴스가
메모리를 차지해버린다는 단점이 있지만, 멀티 쓰레드 동기화 문제에서 자유로울 수 있고 코드가 간결해진다는
장점이 있다. 
 
01.public class MyClass
02.{
03.    private static MyClass m_MyClass = new MyClass();
04.      
05.    private MyClass() {}
06.      
07.    public static MyClass getInstance()
08.    {
09.        return m_MyClass;
10.    }
11.}


Posted by 민구니

Expressing Feelings


1. feel out of place  - 소외당한 느낌.

    ex) 금잔디 feel out of place.

          When I was in CONVERSATION Class. 

          I feel out of place .

          Because I can't hear and speak anything.

          That's why My english is poor. T.T


2. feel suffocated         - suffocate(~의 숨을 막다)

   

3. feel awkward           - awkward(어색한)

   ex) there is an awkward silence


4. get carried away - 동화되다(?)

    - 영화를 보는데 너무 슬퍼서 나도 같이 슬퍼지는 상황.


5. be dumbstruck               - dumbstruck(놀라서 말도 못하는(부정상황))

                                        - speechless (놀라서 말도 못하는(긍정상황))


6. feel insecure                  - insecure(위험에 처한, 무너질든한)

    ex) 내가 1등인데 다른 새로운 사람이 공부를 더 잘할때.


7. feel flattered : Good mistake        - flatter(~에게 아첨하다)

    ex) 누나랑 나랑 있는데 누군가다 "우와 오빠야??" 이렇게 말할때..누나의 느낌

         

8. feel offended                        - offend(성나게 하다)

    ex) 누나랑 나랑 있는데 누군가다 "우와 오빠야??" 이렇게 말할때..나의 느낌.


9. feel frustrated                   - frustrated(실망한, 좌절된)


10. be obsessed with            - 뭔가 한개에 집착만한다.



-COMBINE-


*아래 내용은 위의 내용을 이용하여 작문하기 숙제를 한것이다.

 경험한것만으로 문장을 만들기에는 벅차기에

 사실과 거짓을 적절히 혼합하여 작문을 하였다.


- 설날 is a good day to get some money from older people.

When I went out with my friends to play something in 설날.

Mom phoned me. and Mom said  "Your uncle is coming now"

Then I felt dumbstruck. Because I couldn't go home. so I couldn't get any money.

I got money more than my sister. But If my uncle came to my home.

I will be loser…T.T

anyway I went back home.

actually, My uncle was already gone. I felt frustrated.

And then We go out to have dinner.

When we were walking in the street. We met my sister's friend.

Then sister's friend said "Who is he? your older brother?"

I felt offended……and my sister felt flattered….



1. numbers 6 and 9

I'm a programmer.

I was ACE in my company exclude project manager.

one day someone joined our team as new member.

He has graduated the KIST.

KIST is best of best in korea.

Then I felt insecure. 

but I'm a cool guy. Just enjoy the situation.

however…..Actually It's his first time to make program..

I felt frustrated



2. numbers 10 and 2

When I was BIT that is sparta education center for programer.

I felt suffocated. that's why I couldn't do anything by myself.

I had to study with their rule.

I was typing for some program everyday.

then I felt obsessed with typing for program myself.


3. numbers 1 and  3

When I arrived in the Phillipines.

I met tyler. It's my first time to meet Tyler.

Then I felt awkward.

Anyway, I joined the Conversation class.

Then I can't hear and speak anything.

that's why My English is poor.

Then I felt out of place.


4. numbers 4 and 5

army in korea does basic training for 5weeks.

When the training was finished.

we sang something for our mothers.

suddenly some people cried.

I got carried away.

Then I was crying also.

When the crying ended.

I couldn't believe I was crying..

then I was dumbstruck of myself.


5. numbers 7 and 8

My sister and I go out to have dinner.

When we were walking in the street. We met sister's friend.

Then sister's friend said "Who is he? your older brother?"

I felt offended……and my sister felt flattered….


Posted by 민구니

티스토리 툴바