很簡單,在end select前再多加一種情況case else return "XXXx",因?yàn)槟阒惶峁┝?-9這10種情況
我們提供的服務(wù)有:做網(wǎng)站、網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、霍爾果斯ssl等。為1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的霍爾果斯網(wǎng)站制作公司
Public Function Zuhe(ByVal qa As String) As String
Select Case qa
Case "0"
Return "1"
Case "1"
Return "3"
Case "2"
Return "4"
Case "3"
Return "6"
Case "4"
Return "2"
Case "5"
Return "8"
Case "6"
Return "9"
Case "7"
Return "7"
Case "8"
Return "5"
Case "9"
Return "0"
Case else
Return "XXXX"
End Select
End Function
繼承button,然后增加事件
并且自定義EventArg
思路:
class MyEventArg :EventArg
{
public long MyNum
{
set{ myNum = value;}
get{ return myNum; }
}
private long myNum ;
}
class MyButton:System.Windows.Forms.Button
{
public delegate void MyClick(object sender,MyEventArg e);
public event MyClick OnMyClick;
private MyEventArg myE = new MyEventarg();
protected override void OnClick(EventArgs e)
{
if(OnMyClick != null)
{
OnMyClick(null,myE);
}
base.OnClick(e);
}
}
代碼已測試。
一、測試需要的INI文件。名稱為“setinfo.ini”,存放路徑為你解決方案里“Bin“文件夾的”Debug“文件夾里。
內(nèi)容:
[Location]
pnlTime.Location.X=787
pnlTime.Location.Y=0
[TopMost]
Top=True
二、操作INI文件的類。新建一個(gè)類,類中內(nèi)容為:
Public?Class?Class1
Public?Declare?Function?GetPrivateProfileString?Lib?"kernel32"?Alias?"GetPrivateProfileStringA"?_
(?_
ByVal?lpApplicationName?As?String,?_
ByVal?lpKeyName?As?String,?_
ByVal?lpDefault?As?String,?_
ByVal?lpReturnedString?As?String,?_
ByVal?nSize?As?Int32,?_
ByVal?lpFileName?As?String?_
)?As?Int32
End?Class
三、界面代碼:
Imports?System.IO?'for?path
Public?Class?Form1
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
getINI()
End?Sub
Private?Sub?getINI()
Dim?iniclass?As?New?Class1?'
Dim?myBf?As?String?'get?set_info?開辟存儲(chǔ)的內(nèi)存
myBf?=?New?String(CChar(""),?256)
Dim?myFN?As?String?'配置文件的文件路徑
myFN?=?Path.Combine(My.Application.Info.DirectoryPath,?"setinfo.ini")
Dim?myAN?As?String?'Application_NAME,也是Section名稱
myAN?=?Me.TextBox1.Text
Dim?myKN?As?String?'KEY_NAME,關(guān)鍵字名稱
myKN?=?Me.TextBox2.Text
Class1.GetPrivateProfileString(myAN,?myKN,?"",?myBf,?myBf.Length,?myFN)?'調(diào)用讀取INI文件的操作
TextBox3.Text?=?Microsoft.VisualBasic.Left(myBf,?InStr(myBf,?Chr(0))?-?1)?'截取有用部分,有必要
End?Sub
End?Class
四、測試截圖如下
注意:參數(shù)為動(dòng)態(tài)數(shù)組;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function