| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 357 人关注过本帖
标题:如何让一个combo1的内容去影响另一个combo的内容
只看楼主 加入收藏
yilvyangguan
Rank: 1
来 自:湖北孝感
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-4-30
结帖率:0
收藏
已结贴  问题点数:2 回复次数:5 
如何让一个combo1的内容去影响另一个combo的内容
VB 新手求指点 ,谢了 !
如何让一个combo1的内容去影响另一个combo的内容,如 combo1内容选一个省份,combo2中就显示所选省份包含的城市
搜索更多相关主题的帖子: 如何 影响 
2012-04-30 17:54
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:2 
简单~这我也写过类似的~

不要選我當版主
2012-04-30 23:52
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
用INI~再读取~

不要選我當版主
2012-05-01 00:25
yilvyangguan
Rank: 1
来 自:湖北孝感
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-4-30
收藏
得分:0 
这是我编的 ,可是运行的时候实现不了 求指点
Private Sub Cmbo1_Change(Index As Integer)
With Cmbo1(2)
.Clear
Select Case Cmbo1(1).ListIndex
Case 0
.AddItem "1001班"
.AddItem "1002班"
.AddItem "1003班"
Case 1
.AddItem "2001班"
.AddItem "2002班"
.AddItem "2003班"
Case 2
.AddItem "3001班"
.AddItem "3002班"
.AddItem "3003班"

End Select
End With
End Sub
2012-05-06 15:41
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
资料写在代码中等于写死~
还不如写在外部文件中~
只须在程序中撰写解码器~
执行解译到程序中~
还比较实用~

不要選我當版主
2012-05-07 01:03
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
把资料写死在程序中是很XX的行为~
大大的限缩了程序的拓展性~
程序代码:
Private Sub ComPinG_Click()
Dim Data1() As String, Data2() As String
Dim i As Integer, SelectGroupNum As Integer

On Error GoTo ErrorHandling

    ComPinN.Clear: Erase SelectPin, ResltStatus
    SelectGroupNum = ComPinG.ListIndex + 1
    PinAnalysis.GroupCount = LoadCompareData(SelectGroupNum)
Exit Sub

ErrorHandling:
    Call ErrorWriteBuff(NickName, CStr(i), "ComPinG_Click", Err.Number, Err.Description, "系統訊息")
    Resume Next
End Sub


程序代码:
Private Function LoadCompareData(Num As Integer) As Integer
Dim i As Integer, j As Integer
Dim Temp1() As String, Temp2() As String
    
    ReDim SelectPin(0)
    
    For i = 0 To UBound(Path2)
        Temp1 = Split(Path2(i), ":")
        If UBound(Temp1) = 4 Then
            If InStr(Temp1(0), ".") <> 0 Then
                Temp2 = Split(Temp1(0), ".")
                If UBound(Temp2) = 1 Then
                    If CInt(Val(Temp2(0))) = Num Then
                        If Trim(Temp1(1)) <> "" Then
                            ReDim Preserve SelectPin(j)
                            SelectPin(j) = Val(Temp2(1)) & ". " & Trim(Temp1(1))
                            ComPinN.AddItem SelectPin(j)
                            j = j + 1
                        End If
                    End If
                End If
                Erase Temp2
            End If
        End If
        Erase Temp1
    Next i
    
    LoadCompareData = j - 1
    
End Function


程序代码:
Public Type Unit
    Max As Double
    Min As Double
End Type

Public Type Site_N
    Unit() As String
    Data() As String
    MinValue As Double
    MaxValue As Double
    AvgValue As Double
    MedianValue As Double
    Range() As Unit
End Type

Public Type PinD
    SiteData() As Site_N
    PinCount As Integer
    PinCount1 As Integer
End Type

Public Type Group
    PinData() As PinD
    GroupCount As Integer
End Type

Public PinAnalysis As Group


程序代码:
Private Sub ComPinN_Change()
    .......
End Sub


程序代码:
Private Sub Form_Load()
Dim i As Integer
    Call INILoad
    For i = 0 To TestGroup - 1
        ComPinG.AddItem i + 1
    Next i
End Sub


程序代码:
Public Sub INILoad()
Dim FileNum As Integer, INICount As Integer, i As Integer
Dim FileN As String, TempString As String, Temp() As String
Dim UI As Boolean, CmpData As Boolean

On Error GoTo ErrorHandling
    
    INICount = 0: UI = False: CmpData = False
    FileN = App.Path & "\ABC.ini"
    
    If IsFileExist(FileN) = True Then
        FileNum = FreeFile
        Open FileN For Input As #FileNum
            Do While Not EOF(FileNum)
                Line Input #FileNum, TempString
                TempString = Trim(TempString)
                If TempString <> "" Then
                    If (InStr(TempString, "[") <> 0 And InStr(TempString, "]") <> 0 And InStr(TempString, "UISET") <> 0) Then
                        UI = True: CmpData = False
                    ElseIf (InStr(TempString, "[") <> 0 And InStr(TempString, "]") <> 0 And InStr(TempString, "DATA") <> 0) Then
                        UI = False: CmpData = True
                        TestGroup = Trim(Mid(TempString, InStr(TempString, "_") + 1, InStr(TempString, "]") - InStr(TempString, "_") - 1))
                    End If
                    
                    If UI = True Then
                        If InStr(TempString, "SiteNum_ADD") <> 0 Then
                            SiteStart = CInt(Val(Trim(Mid(TempString, InStr(TempString, "=") + 1))))
                        ElseIf InStr(TempString, "TableLength") <> 0 Then
                            MyStructCount = CInt(Val(Trim(Mid(TempString, InStr(TempString, "=") + 1))))
                        End If
                    ElseIf CmpData = True Then
                        If InStr(TempString, "=") <> 0 Then
                            ReDim Preserve Path1(INICount): ReDim Preserve Path2(INICount)
                            Temp = Split(TempString, "=")
                            If UBound(Temp) = 1 Then
                                Path1(INICount) = Trim(Temp(0))
                                Path2(INICount) = Trim(Temp(1))
                                INICount = INICount + 1
                            End If
                            Erase Temp
                        End If
                    End If
                End If
            Loop
        Close #FileNum
    Else
        MsgBox "Can't Find " & FileN
    End If
        
Exit Sub

ErrorHandling:
    TempString = "Load ABC.ini Error"
    Call ErrorWriteBuff(FileN, CLng(INICount), "INILoad", Err.Number, Err.Description, TempString)
    Resume Next
End Sub

ABC.rar (2.52 KB)


[ 本帖最后由 wube 于 2012-5-7 13:35 编辑 ]

不要選我當版主
2012-05-07 13:30
快速回复:如何让一个combo1的内容去影响另一个combo的内容
数据加载中...
 
   



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

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