很简单,在end select前再多加一种情况case else return "XXXx",因为你只提供了0-9这10种情况
我们提供的服务有:做网站、网站建设、微信公众号开发、网站优化、网站认证、霍尔果斯ssl等。为1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的霍尔果斯网站制作公司
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“文件夹里。
内容:
[Location]
pnlTime.Location.X=787
pnlTime.Location.Y=0
[TopMost]
Top=True
二、操作INI文件的类。新建一个类,类中内容为:
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 开辟存储的内存
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,关键字名称
myKN = Me.TextBox2.Text
Class1.GetPrivateProfileString(myAN, myKN, "", myBf, myBf.Length, myFN) '调用读取INI文件的操作
TextBox3.Text = Microsoft.VisualBasic.Left(myBf, InStr(myBf, Chr(0)) - 1) '截取有用部分,有必要
End Sub
End Class
四、测试截图如下
注意:参数为动态数组;
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