快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

包含vb点虐 num的词条

VB点虐 ,小数点直接进一位的函数?

'自定义一个函数:功能是给小数直接进一位

从事多线服务器托管,服务器租用,云主机,虚拟主机主机域名,CDN,网络代维等服务。

'num  要操作的小数

'n 保留几位小数,

Function getNumber(num As Double, n As Integer) As Double

Dim a As Double

a = Int(num * (10 ^ n)) / (10 ^ n)

If a = num Then

getNumber = a

Else

getNumber = a + 1 / (10 ^ n)

End If

End Function

-------------------------

调用一下:

Private Sub Command1_Click()

MsgBox (getNumber(3.1415926, 2))

End Sub

得到3.15

vb点虐 提取特定字符串

在VB中是这样的,没学过VB点虐 ,你变换一下就可以了

Option

Explicit

Private

Sub

Command1_Click()

Dim

Num(2)

Num(0)

=

Val(Left(Label1.Caption,

2))

Num(1)

=

Val(Mid(Label1.Caption,

3,

1))

Num(2)

=

Val(Right(Label1.Caption,

2))

MsgBox

"Num(0)="

Num(0)

vbCrLf

"Num(1)="

Num(1)

vbCrLf

"Num(2)="

Num(2)

'如果想测试是不是可以计算,可以用这一句

'MsgBox

"Num(0)+1="

Num(0)

+

1

vbCrLf

"Num(1)+1="

Num(1)

+

1

vbCrLf

"Num(2)+1="

Num(2)

+

1

End

Sub

Private

Sub

Form_Load()

Label1.Caption

=

"12345"

End

Sub

使用vb点虐 的字符串

用字符串保存两个数据,当然只有你这种办法,另外提供你其它思路:

1. flexcell增加两列,这两列隐藏不显示,额外数据可以从这两列读取

2. 用自定义类型数组,保存这两列数据,数组顺序和表格一样,或者数组中增加一个ID元素,与表格对应

vb点虐 中 sql查询出来的值,比如books中的remainnum,赋给一个变量 num,再将num-1之后update到remainnum中

Dim num As Integer

Dim connstr, insertcmd, selectcmd As String

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\360data\重要数据\我的文档\hd.mdb"

Dim conn As OleDbConnection

Dim cmd, cmd1 As OleDbCommand

conn = New OleDbConnection(connstr)

Dim r As OleDbDataReader

conn.Open()

insertcmd = "insert into returnbooks (aid,aname,ISBN,bname,renum,reday) values("

Val(ComboBox1.Text) ",'"

TextBox2.Text "','"

ComboBox2.Text "','"

TextBox2.Text "',"

Val(TextBox3.Text) ",'"

CType(TextBox4.Text, Date) "' )"

cmd = New OleDbCommand(insertcmd, conn)

cmd.ExecuteNonQuery()

updatecmd = "update books set remainnum=" Val(num) "-" Val(TextBox3.Text) " where ISBN='" ComboBox2.Text "'"

cmd = New OleDbCommand(updatecmd, conn)

cmd.ExecuteNonQuery()

updatecmd = "select remainnum as num from books where ISBN= '" ComboBox2.Text "'"

cmd = New OleDbCommand(updatecmd, conn)

cmd.ExecuteNonQuery()

updatecom = "update books set remainnum=num+ " Val(TextBox3.Text) ""

cmd = New OleDbCommand(updatecmd, conn)

cmd.ExecuteNonQuery()

selectcmd = "select remainnum from books where ISBN='" ComboBox2.Text "'"

cmd1 = New OleDbCommand(selectcmd, conn)

r = cmd1.ExecuteReader()

If (r.Read()) Then '如果sql查询到了数据

num = r.GetInt32(0)

End If

conn.Close()

/*注意代码的格式,不然改起来太费时间*/


文章题目:包含vb点虐 num的词条
本文路径:http://6mz.cn/article/ddcggie.html

其他资讯