adsense

2012-03-31

LinkWithin 縮圖顯示文章

首先連到網站  點我
打上email blog link  選擇 blogger 
width 是說你要顯示幾則

點安裝


新增迷你組件

放到網誌文章下方
看起來就會像這樣


2012-03-21

自走車 步進馬達


'ServoMotorPULSEOUT.inb : DC Servo Control Using PULSEOUT Command
Const ServoTable(3) As Word ={100,300,500,300} 'PULSEOUT Duration Parameter
Sub main()
Dim I As Byte = 0 'Local Variable
Dim k As Byte
Dim J As Byte 'Local Variable
Low (8) 'Set P8 State to Low
Do
For J=1 To 100 '100 PWM Cycle
Pulseout (8,ServoTable(I)) 'Pulse High
k=(ServoTable(I)*5)\1000:Pause(20-k) 'Pulse Low
'Pause(20-(ServoTable(I)*5)\1000) 'old寫法
Next J
If (I=3) Then I=0 Else I+=1 'Update Index
Loop
End Sub

自走車 蜂鳴器 Do Re Mi


' BuzzerKeyin.inb: Buzzer Control Using SOUND Command
Const Frequency(15) As Word = {523,587,659,698,785,880,988,1047,1046,1174,1318,1396,1570,1760,1976,2094}  'Array for Frequency
Sub main()
Dim key As Short 'Local Variable
Debug CLS,"Press 1 ~ 8 + q ~ u...", CR

Do
Keyin key
'小寫 'k=key-48
If (Key=113) Then Sound(12,250,Frequency(9))
If  (Key=119) Then Sound(12,250,Frequency(10))
If  (Key=101) Then Sound(12,250,Frequency(11))
If  (Key=114) Then Sound(12,250,Frequency(12))
If  (Key=116) Then Sound(12,250,Frequency(13))
If  (Key=121) Then Sound(12,250,Frequency(14))
If  (Key=117) Then Sound(12,250,Frequency(15))
'大寫
If (Key=81) Then Sound(12,250,Frequency(9))
If  (Key=87) Then Sound(12,250,Frequency(10))
If  (Key=69) Then Sound(12,250,Frequency(11))
If  (Key=82) Then Sound(12,250,Frequency(12))
If  (Key=84) Then Sound(12,250,Frequency(13))
If  (Key=89) Then Sound(12,250,Frequency(14))
If  (Key=85) Then Sound(12,250,Frequency(15))

key-=48
If (Key>0 And Key<9) Then Sound(12,250,Frequency(Key-1))




Loop
End Sub

2012-03-20

時間




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

        private DateTime data;
        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "";
            label1.Font = new Font("標楷體", 24, FontStyle.Bold);
            timer1.Interval = 500;
            data = new DateTime(2012, 1, 1);
            this.Text = data.Year.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true;
         
        }

       private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }


        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
         
            label1.Text = data.Month + "月" + data.Day + "日";
           data = data.AddDays(1);
        }

     

        }
    }

2012-03-13

c# 四則運算



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

        private void Form1_Load(object sender, EventArgs e)
        {
            text_all();
            TextChanged_all();
        }

        private void txt_TextChanged(object sender, EventArgs e)
        {
            try
            {
                double n = double.Parse(textBox1.Text) + double.Parse(textBox2.Text);
                textBox3.Text = n.ToString();
            }
            catch (Exception ex)
            { }
        }
        private void txt_TextChanged1(object sender, EventArgs e)
        {
            try
            {
                double n = double.Parse(textBox4.Text) - double.Parse(textBox5.Text);
                textBox6.Text = n.ToString();
            }
            catch (Exception ex)
            { }
        }
        private void txt_TextChanged2(object sender, EventArgs e)
        {
            try
            {
                double n = double.Parse(textBox7.Text) * double.Parse(textBox8.Text);
                textBox9.Text = n.ToString();
            }
            catch (Exception ex)
            { }
        }
        private void txt_TextChanged3(object sender, EventArgs e)
        {
            try
            {
                double n = double.Parse(textBox10.Text) / double.Parse(textBox11.Text);
                textBox12.Text = n.ToString();
            }
            catch (Exception ex)
            { }
        }
        private void text_all()
        {
            textBox1.Text = "0";
            textBox2.Text = "0";
            textBox3.Text = "0";
            textBox4.Text = "0";
            textBox5.Text = "0";
            textBox6.Text = "0";
            textBox7.Text = "0";
            textBox8.Text = "0";
            textBox9.Text = "0";
            textBox10.Text = "0";
            textBox11.Text = "0";
            textBox12.Text = "0";
        }
        private void TextChanged_all()
        {
            textBox1.TextChanged += new EventHandler(txt_TextChanged);
            textBox2.TextChanged += new EventHandler(txt_TextChanged);


            textBox3.TextChanged += new EventHandler(txt_TextChanged);
            textBox4.TextChanged += new EventHandler(txt_TextChanged1);


            textBox5.TextChanged += new EventHandler(txt_TextChanged1);
            textBox6.TextChanged += new EventHandler(txt_TextChanged1);


            textBox7.TextChanged += new EventHandler(txt_TextChanged2);
            textBox8.TextChanged += new EventHandler(txt_TextChanged2);


            textBox9.TextChanged += new EventHandler(txt_TextChanged2);
            textBox10.TextChanged += new EventHandler(txt_TextChanged3);


            textBox11.TextChanged += new EventHandler(txt_TextChanged3);
            textBox12.TextChanged += new EventHandler(txt_TextChanged3);

        }
    }
}

2012-03-05

[excel] REPLACE函式

最近個人資料法的關係 頗多地方都要多下點功夫
所以就造就了這支vba
以下為範例

一開始

點匿名按鈕

點電話按鈕

REPLACE(Sheet1!欄位, 取代字數, 被取代的字串常數, "被取代的字")