| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2589 人关注过本帖
标题:已知,DB,m,偏差等级 同时满足三个条件才能选到需要的数据。程序哪里错误呢 ...
只看楼主 加入收藏
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
结帖率:0
收藏
已结贴  问题点数:10 回复次数:17 
已知,DB,m,偏差等级 同时满足三个条件才能选到需要的数据。程序哪里错误呢?
公差表.rar (42.19 KB)


 Dim d
 d = Array(Array(200, 180, 160, 140, 125, 110, 100, 90, 80), Array(180, 162, 144, 126, 112, 99, 90, 81, 72), Array(160, 144, 128, 112, 100, 88, 80, 72, 64), Array(140, 126, 112, 98, 88, 77, 70, 63, 56), Array(120, 108, 96, 84, 75, 66, 60, 54, 48), Array(100, 90, 80, 70, 62, 55, 50, 45, 40), Array(80, 72, 64, 56, 50, 44, 40, 36, 32), Array(60, 54, 48, 42, 37, 33, 30, 27, 24), Array(40, 36, 32, 28, 25, 22, 20, 18, 16), Array(20, 18, 16, 14, 12, 11, 10, 9, 8), Array(0, 0, 0, 0, 0, 0, 0, 0, 0), Array(-20, -18, -16, -14, -12, -11, -10, -9, -8), Array(-40, -36, -32, -28, -25, -22, -20, -18, -16), Array(-60, -54, -48, -42, -37, -33, -30, -27, -24), Array(-80, -72, -64, -56, -50, -44, -40, -36, -32), Array(-120, -108, -96, -84, -75, -66, -60, -54, -48), Array(-160, -144, -128, -112, -100, -88, -80, -72, -64), Array(-200, -180, -160, -140, -125, -110, -100, -90, -80))

  If m < 1.5 Then
       If DB <= 12 Then
       i = 8
       ElseIf DB > 12 And DB <= 25 Then
       i = 7
       ElseIf DB > 25 And DB <= 50 Then
       i = 6
       ElseIf DB > 50 And DB <= 100 Then
       i = 5
       ElseIf DB > 100 And DB <= 200 Then
       i = 4
       ElseIf DB > 200 And DB <= 400 Then
       i = 3
       Else: i = 2
       End If
 ElseIf m > 1.5 And m <= 4 Then
       If DB <= 12 Then
       i = 7
       ElseIf DB > 12 And DB <= 25 Then
       i = 6
       ElseIf DB > 25 And DB <= 50 Then
       i = 5
       ElseIf DB > 50 And DB <= 100 Then
       i = 4
       ElseIf DB > 100 And DB <= 200 Then
       i = 3
       ElseIf DB > 200 And DB <= 400 Then
       i = 2
       Else: i = 1
       End If
 Else
      
       If DB <= 12 Then
       i = 6
       ElseIf DB > 12 And DB <= 25 Then
       i = 5
       ElseIf DB > 25 And DB <= 50 Then
       i = 4
       ElseIf DB > 50 And DB <= 100 Then
       i = 3
       ElseIf DB > 100 And DB <= 200 Then
       i = 2
       ElseIf DB > 200 And DB <= 400 Then
       i = 1
       Else: i = 0
       End If
  End If
  
  
  If Pc = "v" Then
  j = 0
  ElseIf Pc = "u" Then
  j = 1
  ElseIf Pc = "t" Then
  j = 2
  ElseIf Pc = "s" Then
  j = 3
  ElseIf Pc = "r" Then
  j = 4
  ElseIf Pc = "p" Then
  j = 5
  ElseIf Pc = "n" Then
  j = 6
  ElseIf Pc = "m" Then
  j = 7
  ElseIf Pc = "k" Then
  j = 8
  ElseIf Pc = "j" Then
  j = 9
  ElseIf Pc = "h" Then
  j = 10
  ElseIf Pc = "g" Then
  j = 11
  ElseIf Pc = "f" Then
  j = 12
  ElseIf Pc = "e" Then
  j = 13
  ElseIf Pc = "d" Then
  j = 14
  ElseIf Pc = "c" Then
  j = 15
  ElseIf Pc = "b" Then
  j = 16
  Else: j = 17
  End If
  
 Print d(j)(i)

 End Sub
2016-01-08 16:05
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
Dim i, j, k As Integer
Dim DB, m As Double
Dim Pc As String

Pc = Str(Val(Text1.Text))
是不是定义错了,j一直等于17
2016-01-09 09:01
wmf2014
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:216
帖 子:2039
专家分:11273
注 册:2014-12-6
收藏
得分:0 
其实,我是看不懂你的表,你能不能形象的列出三维表,然后举个查找的例子。看你前面的二维表,我认为有更简单算法,好像两行代码即可。

能编个毛线衣吗?
2016-01-09 09:04
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
问题解决
2016-01-09 09:38
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
3楼的版主,谢谢。能帮我编一个事列吗。
2016-01-09 09:39
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
我的表是  假如基准直径DB <12  , 模数m  大于0.5,小于等于1.5,偏差系列代号为  "v"  则AE=80
2016-01-09 09:43
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
版主能知道我编写一个简单的程序么
2016-01-09 09:43
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
Dim i, j, k As Integer
Dim DB, m As Double
Dim Pc As String
DB = Val(Text1.Text)
m = Val(Text2.Text)
Pc = Text3.Text










 Dim d
 d = Array(Array(200, 180, 160, 140, 125, 110, 100, 90, 80), Array(180, 162, 144, 126, 112, 99, 90, 81, 72), Array(160, 144, 128, 112, 100, 88, 80, 72, 64), Array(140, 126, 112, 98, 88, 77, 70, 63, 56), Array(120, 108, 96, 84, 75, 66, 60, 54, 48), Array(100, 90, 80, 70, 62, 55, 50, 45, 40), Array(80, 72, 64, 56, 50, 44, 40, 36, 32), Array(60, 54, 48, 42, 37, 33, 30, 27, 24), Array(40, 36, 32, 28, 25, 22, 20, 18, 16), Array(20, 18, 16, 14, 12, 11, 10, 9, 8), Array(0, 0, 0, 0, 0, 0, 0, 0, 0), Array(-20, -18, -16, -14, -12, -11, -10, -9, -8), Array(-40, -36, -32, -28, -25, -22, -20, -18, -16), Array(-60, -54, -48, -42, -37, -33, -30, -27, -24), Array(-80, -72, -64, -56, -50, -44, -40, -36, -32), Array(-120, -108, -96, -84, -75, -66, -60, -54, -48), Array(-160, -144, -128, -112, -100, -88, -80, -72, -64), Array(-200, -180, -160, -140, -125, -110, -100, -90, -80))

  If m < 1.5 Then
       If DB <= 12 Then
       i = 8
       ElseIf DB > 12 And DB <= 25 Then
       i = 7
       ElseIf DB > 25 And DB <= 50 Then
       i = 6
       ElseIf DB > 50 And DB <= 100 Then
       i = 5
       ElseIf DB > 100 And DB <= 200 Then
       i = 4
       ElseIf DB > 200 And DB <= 400 Then
       i = 3
       Else: i = 2
       End If
 ElseIf m > 1.5 And m <= 4 Then
       If DB <= 12 Then
       i = 7
       ElseIf DB > 12 And DB <= 25 Then
       i = 6
       ElseIf DB > 25 And DB <= 50 Then
       i = 5
       ElseIf DB > 50 And DB <= 100 Then
       i = 4
       ElseIf DB > 100 And DB <= 200 Then
       i = 3
       ElseIf DB > 200 And DB <= 400 Then
       i = 2
       Else: i = 1
       End If
 Else
      
       If DB <= 12 Then
       i = 6
       ElseIf DB > 12 And DB <= 25 Then
       i = 5
       ElseIf DB > 25 And DB <= 50 Then
       i = 4
       ElseIf DB > 50 And DB <= 100 Then
       i = 3
       ElseIf DB > 100 And DB <= 200 Then
       i = 2
       ElseIf DB > 200 And DB <= 400 Then
       i = 1
       Else: i = 0
       End If
  End If
  

    Select Case Pc
        Case "v"
              j = 0
        Case "u"
             j = 1
            
        Case "t"
              j = 2
        Case "s"
             j = 3
        Case "r"
              j = 4
        Case "p"
             j = 5
        Case "n"
              j = 6
        Case "m"
             j = 7
        Case "k"
              j = 8
        Case "j"
             j = 9
            
        Case "h"
              j = 10
        Case "g"
             j = 11
        Case "f"
              j = 12
        Case "e"
             j = 13
        Case "d"
              j = 14
        Case "c"
             j = 15
            
          Case " b"
              j = 16
        Case Else
            j = 17
    End Select
  
  
  
  
  
  
  
 Print d(j)(i)

 End Sub

2016-01-09 09:44
sr88csg
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2016-1-7
收藏
得分:0 
我现在的程序能用,但是很繁琐。
2016-01-09 09:45
wmf2014
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:216
帖 子:2039
专家分:11273
注 册:2014-12-6
收藏
得分:0 
从你代码上看,可不可以这样理解:
m>4:i的值是根据db的值到0-6变化
m值在1.5-4之间:i的值根据db的值在1-7变化
m<1.5:i的值根据db的值在2-8变化
PC的值好解决

能编个毛线衣吗?
2016-01-09 09:59
快速回复:已知,DB,m,偏差等级 同时满足三个条件才能选到需要的数据。程序哪里 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.249557 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved