Home > April, 2011 存档

[原创]PointFar Spread 使用 RadioButton MultiOption 单选

评分 0.00, 满分 5星 0 票 No comments

想用 PointFar Spread 的 RadioButton MultiOption 进行单选,但是自带的 Spread Designer选择 cell style 为 MultiOption 后没有任何效果,没有checkbox 好用。只好采用代码的方式解决了。

       '1.将以下代码 放入 Form Load 或其他事件中
        With Me.spList4.ActiveSheet
            Dim multiType As New FarPoint.Win.Spread.CellType.MultiOptionCellType
            multiType.Items = New String() {" "}
            For i As Integer = 0 To .RowCount - 1
                    .Cells(i, 0).CellType = multiType
                If i = 0 Then
		'选中第一行,第一列的 0为选中 1为非选
                    .Cells(0, 0).Value = 0
                End If
            Next
        End With
     
   '2.然后加入 以下事件代码 实现单选
    Private Sub spList4_LeaveCell(ByVal sender As System.Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) Handles spList4.LeaveCell
        Me.spList4.ActiveSheet.Cells(e.Row, 0).Value = 1
        Me.spList4.ActiveSheet.Cells(e.NewRow, 0).Value = 0
    End Sub

华氏温标

评分 0.00, 满分 5星 0 票 No comments

一直搞不懂华氏度的0度由来 特意学习了一下
迁居荷兰的德国玻璃工华伦海特也在英国居住过。他经过1709—1714年的研究,把冰、水、氯化铵的混合物平衡温度定为0℉,人体温度定为96℉(如以今天我国标准体温37℃,则应为98.6℉,可见他采用的体温不是今天我国的标准体温),其间分为96格,每格为1℉。1724年,他又把水的沸点定为212℉。但遗憾的是,他未能将冰的熔点定为0℉,而是定为32℉。这就是华氏温标,其符号为tF。
–学习资料–
http://pei.cjjh.tc.edu.tw/~pei/
http://iask.sina.com.cn/b/198641.html

路遇大汽车

评分 0.00, 满分 5星 0 票 No comments


前几天看到3辆新车 5.8L V8进了保税区,过了1周左右就在街上看到 白色的哪个了。

[原创]用户控件 IP文本框 VB.net

评分 0.00, 满分 5星 0 票 No comments

vb.net 的textbox 没有 mask 特地制作一个 以备使用。
源码打包 MyIPBox 附带实例。

Public Class IpBox
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents textBox3 As System.Windows.Forms.TextBox
    Friend WithEvents label3 As System.Windows.Forms.Label
    Friend WithEvents textBox4 As System.Windows.Forms.TextBox
    Friend WithEvents label1 As System.Windows.Forms.Label
    Friend WithEvents textBox1 As System.Windows.Forms.TextBox
    Friend WithEvents label2 As System.Windows.Forms.Label
    Friend WithEvents textBox2 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.textBox3 = New System.Windows.Forms.TextBox
Me.label3 = New System.Windows.Forms.Label
Me.textBox4 = New System.Windows.Forms.TextBox
Me.label1 = New System.Windows.Forms.Label
Me.textBox1 = New System.Windows.Forms.TextBox
Me.label2 = New System.Windows.Forms.Label
Me.textBox2 = New System.Windows.Forms.TextBox
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.SystemColors.Window
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Panel1.Controls.Add(Me.textBox3)
Me.Panel1.Controls.Add(Me.label3)
Me.Panel1.Controls.Add(Me.textBox4)
Me.Panel1.Controls.Add(Me.label1)
Me.Panel1.Controls.Add(Me.textBox1)
Me.Panel1.Controls.Add(Me.label2)
Me.Panel1.Controls.Add(Me.textBox2)
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel1.Location = New System.Drawing.Point(0, 0)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(118, 18)
Me.Panel1.TabIndex = 0
'
'textBox3
'
Me.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.textBox3.Location = New System.Drawing.Point(59, -1)
Me.textBox3.Name = "textBox3"
Me.textBox3.Size = New System.Drawing.Size(24, 14)
Me.textBox3.TabIndex = 11
Me.textBox3.Text = ""
Me.textBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'label3
'
Me.label3.BackColor = System.Drawing.Color.Transparent
Me.label3.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label3.Location = New System.Drawing.Point(83, 1)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(4, 14)
Me.label3.TabIndex = 12
Me.label3.Text = "."
Me.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'textBox4
'
Me.textBox4.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.textBox4.Location = New System.Drawing.Point(87, -1)
Me.textBox4.Name = "textBox4"
Me.textBox4.Size = New System.Drawing.Size(24, 14)
Me.textBox4.TabIndex = 13
Me.textBox4.Text = ""
Me.textBox4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'label1
'
Me.label1.BackColor = System.Drawing.Color.Transparent
Me.label1.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label1.Location = New System.Drawing.Point(27, 3)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(4, 10)
Me.label1.TabIndex = 8
Me.label1.Text = "."
Me.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'textBox1
'
Me.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.textBox1.Location = New System.Drawing.Point(3, -1)
Me.textBox1.Name = "textBox1"
Me.textBox1.Size = New System.Drawing.Size(24, 14)
Me.textBox1.TabIndex = 7
Me.textBox1.Text = ""
Me.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'label2
'
Me.label2.BackColor = System.Drawing.Color.Transparent
Me.label2.Font = New System.Drawing.Font("Arial", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label2.Location = New System.Drawing.Point(55, 1)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(4, 14)
Me.label2.TabIndex = 10
Me.label2.Text = "."
Me.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'textBox2
'
Me.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.textBox2.Location = New System.Drawing.Point(31, -1)
Me.textBox2.Name = "textBox2"
Me.textBox2.Size = New System.Drawing.Size(24, 14)
Me.textBox2.TabIndex = 9
Me.textBox2.Text = ""
Me.textBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
'
'IpBox
'
Me.Controls.Add(Me.Panel1)
Me.Name = "IpBox"
Me.Size = New System.Drawing.Size(118, 18)
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)

    End Sub

#End Region

    Public strIP As String
    Public Property IPAddress() As String
        Get
            strIP = ""
            strIP += IIf(textBox1.Text.Trim() <> "", textBox1.Text.Trim(), "0")
            strIP += "."
            strIP += IIf(textBox2.Text.Trim() <> "", textBox2.Text.Trim(), "0")
            strIP += "."
            strIP += IIf(textBox3.Text.Trim() <> "", textBox3.Text.Trim(), "0")
            strIP += "."
            strIP += IIf(textBox4.Text.Trim() <> "", textBox4.Text.Trim(), "0")
            Return strIP
        End Get

        Set(ByVal Value As String)
            strIP = Value
            Dim arrIP As String() = strIP.Split(".")
            If arrIP.Length > 0 Then
                Try

                    Value = Convert.ToInt32(arrIP(0).Trim)
                    If Value < 0 Then
                        textBox1.Text = "0"
                    ElseIf Value > "255" Then
                        textBox1.Text = "255"
                    Else
                        textBox1.Text = Value.ToString
                    End If

                Catch ex As Exception
                    textBox1.Text = "0"
                Finally
                    textBox1.Text = "0"
                End Try
            End If

            If arrIP.Length > 1 Then
                Try

                    Value = Convert.ToInt32(arrIP(1).Trim)
                    If Value < 0 Then
                        textBox2.Text = "0"
                    ElseIf Value > "255" Then
                        textBox2.Text = "255"
                    Else
                        textBox2.Text = Value.ToString
                    End If

                Catch ex As Exception
                    textBox2.Text = "0"
                Finally
                    textBox2.Text = "0"
                End Try
            End If

            If arrIP.Length > 2 Then
                Try

                    Value = Convert.ToInt32(arrIP(2).Trim)
                    If Value < 0 Then
                        textBox3.Text = "0"
                    ElseIf Value > "255" Then
                        textBox3.Text = "255"
                    Else
                        textBox3.Text = Value.ToString
                    End If

                Catch ex As Exception
                    textBox3.Text = "0"
                Finally
                    textBox3.Text = "0"
                End Try
            End If

            If arrIP.Length > 3 Then
                Try

                    Value = Convert.ToInt32(arrIP(3).Trim)
                    If Value < 0 Then
                        textBox4.Text = "0"
                    ElseIf Value > "255" Then
                        textBox4.Text = "255"
                    Else
                        textBox4.Text = Value.ToString
                    End If

                Catch ex As Exception
                    textBox4.Text = "0"
                Finally
                    textBox4.Text = "0"
                End Try
            End If
        End Set

    End Property


    Private Sub textBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textBox1.TextChanged _
                                                                                                        , textBox2.TextChanged _
                                                                                                        , textBox3.TextChanged _
                                                                                                        , textBox4.TextChanged
        If sender.Text.Trim <> "" Then
            Dim val As Integer = Convert.ToInt32(sender.Text.Trim)
            If val < 0 Then
                sender.Text = "0"
            ElseIf val > 255 Then
                sender.Text = "255"
                sender.SelectionStart = sender.TextLength
            End If
        End If
    End Sub


    Private Sub textBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyDown
        If e.KeyCode = Keys.Right And textBox1.SelectionStart = textBox1.TextLength Then
            textBox2.Focus()
            textBox2.SelectAll()
        End If
    End Sub


    Private Sub textBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox2.KeyDown
        If textBox2.Text.Trim = "" And e.KeyCode = Keys.Back Then
            textBox1.Focus()
            textBox1.SelectionStart = textBox1.Text.Length
        End If
        If e.KeyCode = Keys.Right And textBox2.SelectionStart = textBox2.TextLength Then
            textBox3.Focus()
            textBox3.SelectAll()
        ElseIf e.KeyCode = Keys.Left And textBox2.SelectionStart = 0 Then
            textBox1.Focus()
            textBox1.SelectAll()
        End If
    End Sub


    Private Sub textBox3_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox3.KeyDown
        If textBox3.Text.Trim = "" And e.KeyCode = Keys.Back Then
            textBox2.Focus()
            textBox2.SelectionStart = textBox2.Text.Length
        End If
        If e.KeyCode = Keys.Right And textBox3.SelectionStart = textBox3.TextLength Then
            textBox4.Focus()
            textBox4.SelectAll()
        ElseIf e.KeyCode = Keys.Left And textBox3.SelectionStart = 0 Then
            textBox2.Focus()
            textBox2.SelectAll()
        End If
    End Sub


    Private Sub textBox4_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox4.KeyDown
        If textBox4.Text.Trim = "" And e.KeyCode = Keys.Back Then
            textBox3.Focus()
            textBox3.SelectionStart = textBox3.Text.Length
        End If
        If e.KeyCode = Keys.Left And textBox4.SelectionStart = 0 Then
            textBox3.Focus()
            textBox3.SelectAll()
        End If
    End Sub

    Private Sub textBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox1.KeyPress
        If Char.IsControl(e.KeyChar) Then
        Else
            If Not Char.IsDigit(e.KeyChar) Then
                e.Handled = True
            End If
        End If
        If e.KeyChar = "." Then
            textBox2.Focus()
            textBox2.SelectAll()
        End If
    End Sub


    Private Sub textBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox2.KeyPress
        If Char.IsControl(e.KeyChar) Then
        Else
            If Not Char.IsDigit(e.KeyChar) Then
                e.Handled = True
            End If
        End If
        If e.KeyChar = "." Then
            textBox3.Focus()
            textBox3.SelectAll()
        End If
    End Sub


    Private Sub textBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox3.KeyPress
        If Char.IsControl(e.KeyChar) Then
        Else
            If Not Char.IsDigit(e.KeyChar) Then
                e.Handled = True
            End If
        End If
        If e.KeyChar = "." Then
            textBox4.Focus()
            textBox4.SelectAll()
        End If
    End Sub


    Private Sub textBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textBox4.KeyPress

        If Char.IsControl(e.KeyChar) Then
        Else
            If Not Char.IsDigit(e.KeyChar) Then
                e.Handled = True
            End If
        End If

    End Sub

    Private Sub IpBox_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
         Dim nTextBoxWidth As Integer = (Me.Width - 3 * label1.Width) / 4
            textBox1.Location = New Point(0, 2)
            textBox1.Width = nTextBoxWidth
            textBox1.Height = Me.Height

            label1.Left = textBox1.Right
            label1.Top = 0
            label1.Width = label1.Width
            label1.Height = Me.Height - 4

            textBox2.Left = label1.Right
            textBox2.Top = 2
            textBox2.Width = nTextBoxWidth
            textBox2.Height = Me.Height

            label2.Left = textBox2.Right
            label2.Top = 0
            label2.Width = label1.Width
            label2.Height = Me.Height - 4

            textBox3.Left = label2.Right
            textBox3.Top = 2
            textBox3.Width = nTextBoxWidth
            textBox3.Height = Me.Height

            label3.Left = textBox3.Right
            label3.Top = 0
            label3.Width = label1.Width
            label3.Height = Me.Height - 4

            textBox4.Left = label3.Right
            textBox4.Top = 2
            textBox4.Width = nTextBoxWidth
            textBox4.Height = Me.Height - 4
    End Sub
End Class

精妙 SQL语句

评分 4.00, 满分 5星 1 票 No comments
--说明:复制表(只复制结构,源表名:a 新表名:b) 
select * into b from a where 1<>1 

--说明:拷贝表(拷贝数据,源表名:a 目标表名:b) 
insert into b(a, b, c) select d,e,f from b; 

--说明:显示文章、提交人和最后回复时间 
select a.title
			,a.username
			,b.adddate 
from table a
,(select max(adddate) adddate from table where table.title=a.title) b 

--说明:外连接查询(表名1:a 表名2:b) 
select a.a, a.b, a.c, b.c, b.d, b.f 
from a 
LEFT OUT JOIN b 
	ON a.a = b.c 

--说明:日程安排提前五分钟提醒 
select * from 日程安排 where datediff('minute',f开始时间,getdate())>5 

--说明:两张关联表,删除主表中已经在副表中没有的信息 
delete from info where not exists ( select * from infobz where info.infid=infobz.infid ) 

好风景

评分 0.00, 满分 5星 0 票 No comments

image

rt

HP 安装Windows 2003 问题

评分 0.00, 满分 5星 0 票 No comments

在HP电脑上安装windows 2003 server / Ghost 系统时有时会遇到:
windows could not start because of a computer disk hardware configuration problem could not read from the selected boot disk check boot path and disk hardware. please check the windows documentation about hardware disk configuration  and your hardware refer once manuals for additional information.
在格式化和拷贝完安装文件后第一次重启时提示“因计算机磁盘硬件的配置问题,无法启动。不能读取所选的引导盘,请检查引导路径和磁盘硬件。请参阅文档中有关磁盘配置的信息并参阅您的硬件参考手册,以获得进一步的信息。

只要将BIOS中Power Management Setup中的 WDRT support 禁止掉,windows2003就可以正常启动了

*WDRT是watchdog resource table

断掉 指定数据库的 当前链接

评分 0.00, 满分 5星 0 票 No comments

断掉 当前链接 数据库的 链接,便于恢复数据库。

--终结 数据库连接
--2009-04-18 Edit by Xing
--断掉 当前链接 数据库的 链接,便于恢复数据库。
--

  Use   Master   
    
  Create   Table   #aa(spid   int,ecid   int,status   varchar(300),loginname   varchar(100),hostname   varchar(200),blk   int   ,dbname   varchar(30),cmd   varchar(100),request_id   int)   
  Insert   Into   #aa   Exec   sp_who   
  Declare   tt   Cursor   for   Select   spid   From   #aa   Where   spid>50   and   dbname='DATANAME'   ----dbname   是你的数据库名字   
  Open   tt   
  Declare   @ActiveUserId   Int,@KillString   Varchar(100)   
  Fetch   Next   From   tt   Into   @ActiveUserId   
  While(@@Fetch_Status=0)   
  Begin   
      Set   @KillString='Kill   '+Convert(Varchar(50),@ActiveUserId)   
      Exec(@KillString)   
      Fetch   Next   From   tt   Into   @ActiveUserId   
  End   
  Drop   Table   #aa   
  Close   tt   
  Deallocate   tt