西莫电机圈

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

查看: 1870|回复: 3

[求助] VB与access的查询问题

[复制链接]

签到天数: 14 天

连续签到: 1 天

[LV.3]偶尔看看II

发表于 2012-3-16 19:28 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
请教高手,磁化曲线各数据值存放在access中,VB如何根据磁密B的值求出磁场强度H的值。已经搞懂VB与access的连接问题,多谢赐教!
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过

该用户从未签到

发表于 2012-3-18 09:26 | 显示全部楼层
可能分段线性化吧,以直代曲,感觉有点麻烦啊,不知道有没有更好的方法。
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

发表于 2012-3-27 21:13 | 显示全部楼层
用vb实现表达式求值的算符优先算法
  这是我做的用vb实现表达式求值的算符优先算法的程序,很简单,帖在这,仅供vb新手学习,高手见笑。



'用vb实现表达式求值的算符优先算法
Option Explicit
Dim op(6) As String 'op为运算符集合
Dim optr(20) As String 'optr是运算符栈,我用的数组实现的
Dim opnd(20) As Integer
'opnd是运算数栈,其实本来用的动态数组,后来我嫌麻烦就用的静态的
'运算数和运算符都不能超过20个,反正主要是实现算法
Public optrlen As Integer
Public opndlen As Integer



Public Function inop(c As String, op) As Boolean '判断输入的字符是否为运算符的函数
Dim i As Integer
inop = False
For i = 0 To 6
If op(i) = c Then
inop = True
Exit For
Exit Function
End If
Next i
End Function
Public Sub pushopnd(c As String) '入运算数栈
opnd(opndlen) = c
opndlen = opndlen + 1
End Sub
Public Sub pushoptr(c As String) '入运算符栈
optr(optrlen) = c
optrlen = optrlen + 1
End Sub
Public Function popoptr() As String '出运算符栈
popoptr = optr(optrlen - 1)
optrlen = optrlen - 1
End Function
Public Function popopnd() As String '出运算数栈
popopnd = opnd(opndlen - 1)
opndlen = opndlen - 1
End Function
Public Function gettopoptr() As String '取运算符的栈顶元素
gettopoptr = optr(optrlen - 1)
End Function
Public Function operate(a As Integer, theta As String, b As Integer) '运算函数
If theta = "+" Then
operate = b + a
ElseIf theta = "*" Then
operate = b * a
ElseIf theta = "-" Then
operate = a - b
ElseIf theta = "/" Then
operate = a / b
End If
End Function
Public Function precede(optrtop As String, c As String) As String '比较优先级的函数,相当于查咱数据结构书上的那个优先级表
Select Case optrtop
Case "+"
Select Case c
Case "+", "-", ")", "#"
precede = ">"
Case "*", "/", "("
precede = "<"
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case "-"
Select Case c
Case "+", "-", ")", "#"
precede = ">"
Case "*", "/", "("
precede = "<"
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case "*"
Select Case c
Case "+", "-", ")", "#", "*", "/"
precede = ">"
Case "("
precede = "<"
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case "/"
Select Case c
Case "+", "-", ")", "#", "*", "/"
precede = ">"
Case "("
precede = "<"
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case "("
Select Case c
Case "+", "-", "(", "*", "/"
precede = "<"
Case ")"
precede = "="
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case ")"
Select Case c
Case "+", "-", ")", "#", "*", "/"
precede = ">"
Case "("
MsgBox ("不允许出现‘)’,‘(’的情况!")
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case "#"
Select Case c
Case "+", "-", "(", "*", "/"
precede = "<"
Case "#"
precede = "="
Case ")"
MsgBox ("不允许出现‘#’,‘)’的情况!")
Case Else
MsgBox ("新读入的字符不是运算符!")
End Select
Case Else
MsgBox ("运算符栈的栈顶字符不是运算符!")
End Select
End Function



Private Sub Command1_Click()
Dim getchar As String
Dim popoptrchar As String
Dim popopndchara As Integer
Dim popopndcharb As Integer
Dim operatechar As Integer
Dim jieguo As String
Do While gettopoptr <> "#" '运算,直到运算符栈是“#”时
popopndcharb = popopnd()
popopndchara = popopnd()
popoptrchar = popoptr
operatechar = operate(popopndchara, popoptrchar, popopndcharb)
pushopnd (operatechar)
Loop
jieguo = popopnd()
Text2.Text = jieguo '显示结果
End Sub



Private Sub Command2_Click()
Unload Me
End Sub



Private Sub Form_Load()
optrlen = 1
opndlen = 0
op(0) = "+" '初始化运算符集合
op(1) = "-"
op(2) = "*"
op(3) = "/"
op(4) = "("
op(5) = ")"
op(6) = "#"
optr(0) = "#"
End Sub



Private Sub Text1_KeyPress(KeyAscii As Integer)
'输入的字符相当与c=getchar
'keypress事件正好是输入一个字符执行一次,就省着做循环了,这是vb的优点也正是我用vb的初衷
Dim getchar As String
Dim popoptrchar As String
Dim popopndchara As Integer
Dim popopndcharb As Integer
Dim operatechar As Integer
getchar = Chr(KeyAscii)
If (Not inop(getchar, op)) Then
pushopnd (getchar)
Else
Select Case precede(gettopoptr(), getchar)
Case "<"
pushoptr (getchar)
Case "="
popoptrchar = popoptr()
Case ">"
popopndcharb = popopnd()
popopndchara = popopnd()
popoptrchar = popoptr
operatechar = operate(popopndchara, popoptrchar, popopndcharb)
pushopnd (operatechar)
If getchar = ")" Then
popoptrchar = popoptr
End If
If getchar <> "#" And getchar <> ")" Then pushoptr (getchar)



Case Else
MsgBox ("嘿嘿,对不起,出现了我意想不到的错误。")
End Select
End If
End Sub
注:此程序在win98,vb6下调试通过。
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

该用户从未签到

发表于 2013-10-2 08:01 | 显示全部楼层
两方面1.解决VB与access联接;2采用线性插值或抛物插值等方法。
西莫电机论坛微信公众平台正式上线!★详情请点击★ 西莫电机论坛会员交流专用群欢迎您西莫电机论坛加群请注明论坛用户名及所从事专业,否则不予通过
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|西莫电机圈 ( 浙ICP备10025899号-3 浙公网安备:33028202000436号

GMT+8, 2024-11-25 14:56 , Processed in 0.101827 second(s), 27 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表