« Previous : 1 : 2 : 3 : 4 : 5 : ... 114 : Next »

블루네군 블로그, 6년 되다,,,,

이 블로그도, 2004년 8월 16일로 부터 첫 시작해서,,
오늘로 만 6년을 맞이 하는거 같습니다,,,

뭐, 정확하게 더 이야기 하자면 첫 시작은 그보다 훨씬 전에 시작하였지만,
제가 왕창 실수 하는 바람에 디비를 홀라당 까먹어 버렸습니다...ㅎㅎ

블로그 관리에 많이 게을리즘 해, 포스팅 횟수도 많이 부족하고 그러지만,,,ㅋㅋ
방문자 40만명.... 나쁘진 않군요,,,ㅎㅎ

귀차니즘을 극복해서.. 올해 안으로 ... 구글애드센스 다시 한번 타 볼랍니다...ㅎㅎ

Posted by 블루네군

2010/08/16 19:14 2010/08/16 19:14
Response
No Trackback , No Comment
RSS :
http://bluene.net/blog/rss/response/532

[C#] 윈폼으로 로또 번호 추출기 만들기

C#, 윈도우 폼을 이용하여,
(아주 딥하게 말씀드리면, label하나, 텍스트 박스 여섯개, 버튼 한개)초 간단하게, 로또 번호 추출기를 만들어 보고자......
일단 소스만 올립니다.

using System;
using System.Windows.Forms;

namespace WinFrmLotto
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int[] lot = new int[6]; //결과값을 담을 배열
        int digit = 0;

        Random rnd = new Random();
        
        private bool Numbers(int Num)
        {
            bool selection = false;
            for (int i = 0; i < lot.Length; i++)
            {
                if (lot[i] == Num)
                {
                    selection = true;
                    break;
                }
            }
            return selection;
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            int i = 0;
            while (i != 6)
            {
                digit = rnd.Next(1, 46);
                if (!Numbers(digit))
                {
                    lot[i] = digit;
                    i++;
                }
            }
            Array.Sort(lot);
            textBox1.Text = lot[0].ToString();
            textBox2.Text = lot[1].ToString();
            textBox3.Text = lot[2].ToString();
            textBox4.Text = lot[3].ToString();
            textBox5.Text = lot[4].ToString();
            textBox6.Text = lot[5].ToString();
        }
    }
}

저기 textBox?.Text 다음줄로 각각. Thread.Sleep(500); 정도 를 넣어주심 더 재미있는 효과가 나타날지도 ㅎㅎㅎ

Posted by 블루네군

2010/07/24 21:38 2010/07/24 21:38
Response
No Trackback , No Comment
RSS :
http://bluene.net/blog/rss/response/531

C#에서 ListView로 쌓아둔 내용(?)을 ... Excel로 저장하기 위한 소스 코드입니다.
Excel로 저장하기 위해서 처리한 Method만 올려 놓았습니다.
(실행 파일 및 스크린 샷은 첨부 하지 않았습니다.)

private void btnSaveExcel_Click(object sender, EventArgs e)
        {
            if (btnOpen.Visible == false)
            {
                MessageBox.Show("저장전 Port를 Close하세요!");
            }
            else
            {
                //엑셀 저장하기
                saveFileDialog1.CreatePrompt = true;
                saveFileDialog1.OverwritePrompt = true;
                
                saveFileDialog1.DefaultExt = "*.xls";
                saveFileDialog1.Filter = "Excel Files (*.xls)|*.xls";
                saveFileDialog1.InitialDirectory = "C:\\";

                DialogResult result = saveFileDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {
                    try
                    {
                        object missingType = Type.Missing;
                        Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
                        Microsoft.Office.Interop.Excel.Workbook excelBook = excelApp.Workbooks.Add(missingType);
                        Microsoft.Office.Interop.Excel.Worksheet excelWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelBook.Worksheets.Add(missingType, missingType, missingType, missingType);
                        excelApp.Visible = false;

                        for (int i = 0; i < lstView.Items.Count; i++)
                        {
                            for (int j = 0; j < lstView.Columns.Count; j++)
                            {
                                if (i == 0)
                                {
                                    excelWorksheet.Cells[1, j + 1] = this.lstView.Columns[j].Text;
                                }
                                excelWorksheet.Cells[i + 2, j + 1] = this.lstView.Items[i].SubItems[j].Text;
                            }
                        }
                        excelBook.SaveAs(@saveFileDialog1.FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, missingType, missingType, missingType, missingType, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, missingType, missingType, missingType, missingType, missingType);
                        excelApp.Visible = true;
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                    }
                    catch
                    {
                        MessageBox.Show("Excel 파일 저장중 에러가 발생했습니다.");
                    }
                }
            }
        }

Posted by 블루네군

2010/07/11 00:01 2010/07/11 00:01
Response
No Trackback , No Comment
RSS :
http://bluene.net/blog/rss/response/530

« Previous : 1 : 2 : 3 : 4 : 5 : ... 114 : Next »

Archives

Calendar

«   2010/09   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    

Site Stats

Total hits:
407324
Today:
34
Yesterday:
214