vb.net创建函数 vb创建excel

VB.NET自定义函数

很简单,在end select前再多加一种情况case else return "XXXx",因为你只提供了0-9这10种情况

成都创新互联公司于2013年创立,先为交城等服务建站,交城等地企业,进行企业商务咨询服务。为交城企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

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

VB.NET 如何带参数构造函数对象或是类

public structure struc

public name as string

public shengao as integer

……

end structure

public items as struc()

readonly property people(argname as string) as struc

get

for each i as struc in items

if i.name=argname then reture i

next

end get

end property

struc可以用class,property可以用function,people通过参数返回一个对象,对象可以来源于某个数组的某个元素,也可以是其他来源。

people也可以是类的构造方法,而shengao等是类的成员,但你的写法是错误的,构造方法必须用new实例化

vb.net 编写一个函数

注意:参数为动态数组;

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

使用vb.net编写一个函数,函数只有一个参数

首先在窗体上添加Button1,ListBox1,下面是完整代码

Public Class Form1

Public Sub BubbleSort(ByVal arr() As Integer) '冒泡法排序

Dim temp As Double

Dim i, j As Integer

For i = 0 To arr.GetUpperBound(0) - 1

For j = i + 1 To arr.GetUpperBound(0) - 1

If arr(i)  arr(j) Then

temp = arr(j)

arr(j) = arr(i)

arr(i) = temp

End If

Next

Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '调用

Dim arr() As Integer = {55, 22, 33, 11, 77, 88}

BubbleSort(arr) '调用排序过程

Me.ListBox1.Items.Clear()

For i = 0 To arr.GetUpperBound(0) - 1 '显示排序后结果

Me.ListBox1.Items.Add(arr(i).ToString)

Next

End Sub

End Class

vb.net随机函数生成~!

//太蛋疼了,我没注意到是vb.net,写成C#的了。。。。

//也许不是太完美,但功能上还是实现了

//protected void Timer1_Tick(object sender, EventArgs e)

//{

// Random rnd = new Random((int)DateTime.Now.Ticks);

// double result = rnd.NextDouble() * 3.0;

// if (result 1.1)

// {

// result += 1.1;

// }

// Label1.Text = string.Format("{0:0.0}", result);

//}

'下面这个就是VB.NET的了

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Randomize()

Dim result As Single = Rnd() * 3.0

If (result 1.1) Then

result += 1.1

End If

Label1.Text = String.Format("{0:0.0}", result)

End Sub

VB.net环境中,我要编写一个函数,要求返回一个DataSet,请问如何定义这个函数?

Public Function getmastt(aUser As Variant, scustid As Variant, ssaleas As Variant) As ADODB.Recordset

Dim adoRs As New ADODB.Recordset

Dim sTableName(0) As String, sFullName(0) As String, sDsn(0) As String

Dim sWhere As String

Set oGetPath = CreateObject("M2000UTIL.GETPATH")

sTableName(0) = "QCHKAPPCON"

oGetPath.getpath aUser, sTableName(), Null, sFullName(), sDsn()

sWhere = ""

sWhere = sWhere + " and a.custid= '" scustid "' and a.saleas='" ssaleas "'"

sSql = "select * from " sFullName(0) " a where 1=1 " sWhere

sSql = sSql + " order by a.CUSTID"

With adoRs

.CursorLocation = adUseClientBatch

.CursorType = adOpenKeyset

.LockType = adLockBatchOptimistic

.Open sSql, sDsn(0)

End With

Set getmastt = adoRs

Set adoRs = Nothing

End Function


本文题目:vb.net创建函数 vb创建excel
分享路径:http://scyanting.com/article/dodgcch.html