본문 바로가기

전체 글156

[vb.net] "하드코딩"과 "소프트코딩"(로딩) 오래간만에 질문이 올라온 글을 보다가 아래와 같은 소스를 발견하였다.​ Select Case m_cmbSaveAs.Text Case "*.bmp" m_bitmap.Save(strFileName, ImageFormat.Jpeg) Case "*.jpg" m_bitmap.Save(strFileName, ImageFormat.Jpeg) Case "*.gif" m_bitmap.Save(strFileName, ImageFormat.Gif) Case "*.tif" m_bitmap.Save(strFileName, ImageFormat.Tiff) End Select 이와 같은 소스를 아래처럼 줄일 수 있다 Dim extension As String = IO.Path.GetExtension(strFileName).ToLo.. 2022. 6. 29.
[vb.net] URL 이미지 Image 변환 및 저장 Dim URL As String = "http://program1472.com/data/common/6e78fa096f9750e12db6.png"Dim img As Image = System.Drawing.Image.FromStream(Net.WebRequest.Create(URL).GetResponse().GetResponseStream())img.Save(APP_PRODUCT_PATH & "\test.png", Imaging.ImageFormat.Png) 또는 Dim URL As String = "http://program1472.com/data/common/6e78fa096f9750e12db6.png"Dim img As Image = Bitmap.FromStream(New IO.MemoryStrea.. 2022. 6. 26.
[vb.net] DataGridView 헤더 병합 dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing dgv.ColumnHeadersHeight *= 2 AddHandler dgv.Paint, Sub(ByVal sd As Object, ByVal ee As PaintEventArgs) Dim monthes As String() = {"Total", "Correct", "Wrong", "Score"} Dim j As Integer = 3 Dim pDGV As DataGridView = CType(sd, DataGridView) Try While j 2021. 5. 2.
[vb.net] Merge DataGridView Cells / DataGridView 셀병합 HMergedCell.vb Imports System Imports System.Collections.GenericImports System.ComponentModelImports System.DataImports System.DrawingImports System.TextImports System.Windows.FormsImports System.DiagnosticsImports System.Drawing.Drawing2D Public Class HMergedCell Inherits DataGridViewTextBoxCell Private m_nLeftColumn As Integer = 0 Private m_nRightColumn As Integer = 0 Private m_nTopRow As Int.. 2021. 5. 2.
[VBNET] 크로스 스레드 (Cross Thread) 예제 '// Example 컨트롤 삽입 Dim DL As New DGV_LIST If CType(Me.Panel10.Controls("RP"), DGV_LIST).GroupBox1.InvokeRequired = True Then CType(Me.Panel10.Controls("RP"), DGV_LIST).GroupBox1.Invoke(CType(Function() CType(Me.Panel10.Controls("RP"), DGV_LIST).GroupBox1.Controls.Add(DL) End Function, MethodInvoker)) Else CType(Me.Panel10.Controls("RP"), DGV_LIST).GroupBox1.Controls.Add(DL) End If '// Example 01.. 2021. 5. 2.
[vb.net] DataTable Count / Sum / Distinct '// 정렬 후 유일한 값 추출 Dim DA() As String = D.Select("", "testPaperNum ASC").CopyToDataTable.AsEnumerable().Select(Function(DR) Return DR.Field(Of Long)("testPaperNum").ToString End Function).Distinct().ToArray '// 특정 조건 데이터 갯수 Count = D.Select(String.Format("[testPaperNum]='{0}' AND [Difficulty]='{1}' AND [correct]='{2}'", DA, DB, 0)).Length 또는 Count = D.Compute("count(testPaperNum)", String.Format(.. 2021. 5. 2.
vb.net 컨트롤이 자신이 만들어진 스레드가 아닌 스레드에서 액세스되었습니다. '쓰레드 생성을 위한 변수 선언 Dim t As System.Threading.Thread '크로스 쓰레드 작업을 위한 콜백 대리자 선언 Delegate Sub textCallBack(ByVal state As Object) '콜백 대리자 변수 선언 Dim cbFunc As textCallBack Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '쓰레드 생성 후 newThreadFunc 호출 t = New System.Threading.Thread(AddressOf newThreadFunc) '쓰레드 시작 & 인수 = "Hello World" t.Start(CObj("H.. 2021. 5. 2.
[vb.net] TextBox Ctrl+c and Ctrl+v how to implement Private Function SET_TEXT_BOX_CLIPBOARD_SHORTCUTS(ByRef f As Form) As Boolean Dim C As Control = f Do C = f.GetNextControl(C, True) Try Select Case True Case C Is Nothing Case TypeOf C Is TextBox AddHandler CType(C, TextBox).KeyUp, AddressOf TextBox_KeyUp End Select Catch ex As Exception el.WriteToErrorLog(ex.Message, ex.StackTrace, "Error") End Try Loop Until C Is Nothing End Function Private S.. 2021. 3. 18.
[VB.NET] Sort Examples: Arrays and Lists - Dot Net Perls VB.NET program that uses Array.Sort on stringsModule Module1 Sub Main() ' Create an array of String() with 3 elements. Dim vegs As String() = New String() {"turnip", "onion", "corn"} ' Use the System.Array.Sort shared method. System.Array.Sort(vegs) ' Loop through the results and print them with Console.WriteLine. For Each value As String In vegs Console.WriteLine(value) Next End Sub End Module .. 2021. 3. 18.
[VB.NET] program that uses WithEvents, Handles Module Module1 ' An instance of the Event class. WithEvents EventClassInstance As New EventClass Sub PrintTestMessage() Handles EventClassInstance.TestEvent ' This method handles the TestEvent. Console.WriteLine("Test Message Being Printed...") End Sub Sub PrintTestMessage2() Handles EventClassInstance.TestEvent ' This method also handles the event. Console.WriteLine("Test Message 2 Being Printe.. 2021. 3. 10.
[MySQL] MySQL 공백, 탭, 라인피드, 캐리지리턴 등을 제거하는 방법 MySQL 공백, 탭, 라인피드, 캐리지리턴 등을 제거하는 방법 필드값 변경 함수 replace(필드명, 변경할 문자, 변경될 문자) - '필드명'에 해당하는 레코드에서 '변경할 문자'를 모두 '변경될 문자'로 변경한다. 1. 공백제거(앞/뒤의 공백을 제거한다) - update table set field = replace(field, ' ', ''); * table은 테이블명, field는 필드명이다. 2. 개행문자 제거 - update table set field = replace(field, '\r\n', ''); 3. 탭( Tab - char(9) ) 제거 - update table set field = replace(field, char(9), ''); - field 값에 탭(char(9))이 .. 2021. 2. 24.
[MySQL] 내용 추가 / 값 추가 UPDATE `job_order` SET `InvoiceNumber` = concat(`InvoiceNumber`, '추가할값') WHERE `uid` = 1 2021. 2. 23.
mysql DB에서 쿼리에 영향을 줄 수 있는 문자열이나 특수문자 등을 확인하고 처리 mysql DB에서 쿼리에 영향을 줄 수 있는 문자열이나 특수문자 등을 확인하고 처리해야합니다. 이 방법으로 아래의 함수를 이용해 확인 가능합니다. mysqli_real_escape_string($dbc, 처리할 문자열); 2021. 2. 22.
특수문자 리스트 ~ ! @ # $ % ^ & * \ " ' + = ` | ( ) [ ] { } : ; - _ - # & & @ § ※ ☆ ★ ○ ● ◎ ◇ ◆ □ ■ △ ▲ ▽ ▼ → ← ← ↑ ↓ ↔ 〓 ◁ ◀ ▷ ▶ ♤ ♠ ♡ ♥ ♧ ♣ ⊙ ◈ ▣ ◐ ◑ ▒ ▤ ▥ ▨ ▧ ▦ ▩ ♨ ☏ ☎ ☜ ☞ ¶ † ‡ ↕ ↗ ↙ ↖ ↘ ♭ ♩ ♪ ♬ ㉿ ㈜ № ㏇ ™ ㏂ ㏘ ℡ ® ª º ─ │ ┌ ┐ ┘ └ ├ ┬ ┤ ┴ ┼ ━ ┃ ┏ ┓ ┛ ┗ ┣ ┳ ┫ ┻ ╋ ┠ ┯ ┨ ┷ ┿ ┝ ┰ ┥ ┸ ╂ ┒ ┑ ┚ ┙ ┖ ┕ ┎ ┍ ┞ ┟ ┡ ┢ ┦ ┧ ┩ ┪ ┭ ┮ ┱ ┲ ┵ ┶ ┹ ┺ ┽ ┾ ╀ ╁ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ + - < = > ± × ÷ ≠ ≤ ≥ ∞ ∴ ♂ ♀ ∠ ⊥ ⌒ ∂ ∇ ≡ ≒ ≪ ≫ √ ∽ ∝ ∵ .. 2021. 2. 9.
[vb.net] JSON 기본 정리 Imports Newtonsoft.Json Dim Result as String = [JSON_문자열] Dim tmpJson as JObject = JObject.Parse(Result) Dim tmp as String = tmpJson([key]) 반대로 Dim tmpJson As New JObject() With tmpJson .Add("A", A_Value) .Add("B", B_value) End With Dim tmp as String = tmpJson.ToString() 아래와 같은 방법을 활용할 수 있습니다. Dim json As Object json = New With {Key .key1 = "value1", .key2 = "value2"} MsgBox(json.ToString) Dim j.. 2021. 2. 8.
[vb6.0/vba] 숫자를 한글 또는 한자로 변환하는 법 출처: VBA6- 숫자를 한글 또는 한자로 변환하는 법Public Function ReadNum(Num, ReadType) Dim L, k, i, j, n, v As Integer Dim Tg1, Tg2, Tg3 As Variant Dim g1, g2, g3 As Integer Dim Ans As String If ReadType = 1 Then' Tg1 = Array("", "壹", "貳", "參", "四", "五", "六", "七", "八", "九") Tg1 = Array("", "1", "2", "3", "4", "5", "6", "7", "8", "9") Tg2 = Array("", "拾", "百", "千") Tg3 = Array("", "萬", "億", "兆") Else' Tg1 = Array(.. 2021. 1. 30.
[vb6.0/vba] 한글을 자음 모음으로 나누기 + 합치기 출처: 한글을 자음 모음으로 나누기 + 합치기 Function fnName(inName As String) As String Dim 초성 As Variant, 중성 As Variant, 종성 As Variant Dim vr() As Variant Dim i As Integer, j As Integer, n As Long, k1 As Integer, k2 As Integer, k3 As Integer 초성 = Array("ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ") 중성 = Array("ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", ".. 2021. 1. 30.
[공유] 메일 프로토콜 개념 ( POP3, IMAP, SMTP ) POP3 : Post Office Protocol 3IMAP와 비교할때 그냥 단순이 뷰어라고 보면된다.(단방향)메일서버에서 내쪽으로 전달의 개념.삭제를 해도 원본은 지워지지 않는다.ex) 스마트폰에서 메일설정을 pop3로 설정 후 삭제를 해도 메일계정의 메일은 지워지지 않는다. 메일 클라이언트가 메일을 사용자 자신의 PC로 다운로드할 수 있도록 해주는 프로토콜을 말한다.현재 대부분의 메일서버에서는 POP3을 사용하고 있으며 사용자는 넷스케이프나 아웃룩 익스프레스로 서버에 있는 자신의 메일 수신함을 체크하여 메일을 자신의 컴퓨터로 수신한다. 메일을 수신하는 프로토콜에는 POP3와 IMAP(Internet Message Access Protocol)가 있는데, IMAP은 서버에 직접 접속해 메일을 관리하는데.. 2021. 1. 30.
[vb.net] 주어진 비율을 유지하면서 마우스로 사각형을 그립니다 Dim mRect As Rectangle Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs) mRect = New Rectangle(e.X, e.Y, 0, 0) Me.Invalidate() End Sub Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs) If e.Button = Windows.Forms.MouseButtons.Left Then mRect = New Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top) 'Replace 1.5 with the scale you want to use Dim hgt As I.. 2021. 1. 30.
[vb.net] Boolean(True/False) 의 값과 연산 결과값 True * 1 = -1 False * 1 = 0 True + 2 = 1 False + 2 = 2 응용::) Public isWork As Boolean Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click isWork = Not isWork Button1.Text = Choose(isWork + 2, "중 지", "시 작") Work.Enabled = isWork End Sub 2021. 1. 30.
[vb6.0/vba] MSXML2.XmlHttp와 MSXML2.DOMDocument 를 이용한 www.kimsonline.co.kr 크롤링 Sub Test() Dim pData As String Dim url As String Dim sHtml As String Dim r As Long '// https://www.kimsonline.co.kr/drugcenter/search/retotalsearch?Keyword=%EA%B8%80%EB%A6%AC%EB%A9%9C&Page=1 url = "https://www.kimsonline.co.kr/Function/GetTotalSearch" '// Post문자열 pData = "{""parameters"":[{""Key"":""TotalSearchKeyword"",""Value"":""글리멜""}," & _ "{""Key"":""MarketStatus"",""Value"":""AS""}, " & _.. 2021. 1. 30.