tryagaaa

VB6.0 to VBA  Conversion

Discussion created by tryagaaa on Apr 28, 2011
Latest reply on Apr 30, 2011 by tryagaaa
Can anyone help me?
I have some code conversion problem....


here's the code....

Private Sub Combo2_CLICK()
Label10.Caption = "C" & _
    (Combo2.ItemData(Combo2.ListIndex) / 100)
End Sub

Private Sub Combo3_click()
Label13.Caption = "K" & _
    (Combo3.ItemData(Combo3.ListIndex) / 100)

End Sub

Private Sub Form_Load()
    Combo1.AddItem "a"
    Combo1.ItemData(Combo1.NewIndex) = 99
    Combo1.AddItem "b"
    Combo1.ItemData(Combo1.NewIndex) = 71
    Combo1.AddItem "c"
    Combo1.ItemData(Combo1.NewIndex) = 65

End Sub

Private Sub Combo1_click()
    Select Case Combo1.ListIndex
          Case 0
            Combo2.Clear
             Combo2.AddItem "cc"
            Combo2.ItemData(Combo2.NewIndex) = 99
            Combo2.AddItem "dd"
            Combo2.ItemData(Combo2.NewIndex) = 97
            Combo2.AddItem "bb"
            Combo2.ItemData(Combo2.NewIndex) = 99
            
            
          Case 1
            Combo2.Clear
            Combo2.AddItem "cc"
            Combo2.ItemData(Combo2.NewIndex) = 71
            Combo2.AddItem "bb"
            Combo2.ItemData(Combo2.NewIndex) = 84
            Combo2.AddItem "dd"
            Combo2.ItemData(Combo2.NewIndex) = 88
           
            
            
        Case 2
            Combo2.Clear
            Combo2.AddItem "cc"
            Combo2.ItemData(Combo2.NewIndex) = 65
            Combo2.AddItem "bb"
            Combo2.ItemData(Combo2.NewIndex) = 48
            Combo2.AddItem "dd"
            Combo2.ItemData(Combo2.NewIndex) = 51
                      
      
          End Select
Select Case Combo1.ListIndex
                     
            
          Case 1
           
            Combo3.Clear
            Combo3.AddItem "dd"
            Combo3.ItemData(Combo3.NewIndex) = 70
            Combo3.AddItem "gg"
            Combo3.ItemData(Combo3.NewIndex) = 66
            
         Case 2
           
            Combo3.Clear
            Combo3.AddItem "gg"
            Combo3.ItemData(Combo3.NewIndex) = 74
       
            
            
      
          End Select
End Sub
Private Sub Command3_Click()
Dim Qt As Single
Dim a As Single
Dim c As String



i = Text9.Text
a = Text10.Text


If Text15.Text = "" Then
c = Text15.Text
Else
c = Combo2.ItemData(Combo2.ListIndex) / 100
End If


Qt = Val(c) * i * a

Text13.Text = Qt
Exit Sub

errorhandler:
MsgBox "Please Check Your Data!"

End Sub
Private Sub Command2_Click()
On Error GoTo errorhandler


Dim Rn As Long
Dim u As Long
Dim es As Long
Dim ea As Long
Dim K As Long
Dim Ht As Long
Dim ET0 As Single


Rn = Text5.Text
u = Text3.Text
es = Text4.Text
ea = Text6.Text
K = Text7.Text
Ht = Text8.Text


Delta = (4098 * (0.618 * Exp((17.27 * Ht) / (Ht + 237.3)))) / (Ht + 237.3) ^ 2

Gamma = (0.001013 * ea) / (0.622 * 2.45)

ET0 = (0.408 * Delta * Rn + Gamma * (900 / (Ht + 273)) * u * (es - ea)) / (Delta + Gamma * (1 + 0.34 * u))

Text12.Text = ET0

Exit Sub

errorhandler:
MsgBox "Please Check Your Data!"


End Sub
Private Sub Command1_Click()


i = Text1.Text 
i2 = Text2.Text 

Dim T As Integer
Dim Tmax As Integer
Dim Smax As Single
Dim s As Integer
Dim det As Single
Dim st As Integer
Dim Qt As Single
Dim st1 As Single
Dim R1 As Single
Dim R As Integer

R1 = Text14.Text

Smax = 1
st = Smax
T = 1


det = Text12.Text 

Qt = Text13.Text

Do Until R > R1
Do Until T > Tmax

If i >= i2 Then
  If st >= det Then
    dt = det
  
  Else
    dt = st
    
  End If
 
 Else
 dt = 0
 
End If


st1 = Qt + st - dt 

Label1.Caption = st1

If st1 >= Smax Then
       st1 = Smax
       Else
       st1 = st1
       End If
       
If Qt >= det Then
Qtc = Qtc + 1
Else
Qtcf = Qtcf + 1
End If

If i >= i2 Then
ic = ic + 1
Else
icf = icf + 1
End If

If st1 >= det Then
st1c = st1c + 1
Else
st1cf = st1cf + 1
End If


If Qt + st1 >= det + i2 Then
Qst1c = Qst1c + 1
Else
Qst1cf = Qstc1f + 1
End If




R = (Qtc + ic + st1c + Qst1c) / (Qtc + ic + st1c + Qst1c + Qtcf + icf + st1cf + Qst1cf)
T = T + 1
Label8.Caption = R


Loop

Exit Sub
Loop
Exit Sub


errorhandler:
MsgBox "Please Check Your Data!"






End Sub



I try to do it myself  but it's stock with combobox in the first

Private Sub ComboBox1_click()
    Select Case ComboBox1.ListIndex
    
             
             Case 0
            ComboBox2.Clear
            ComboBox2.AddItem "0"
            ComboBox2.Value = 99
            ComboBox2.AddItem "10"
            ComboBox2.Value = 97
            ComboBox2.AddItem "20"
            ComboBox2.Value = 99
            
            
          Case 1
            ComboBox2.Clear
            ComboBox2.AddItem "0"
            ComboBox2.Value = 71
            ComboBox2.AddItem "10"
            ComboBox2.Value = 84
            ComboBox2.AddItem "20"
            ComboBox2.Value = 88
           
            
            
        Case 2
            ComboBox2.Clear
            ComboBox2.AddItem "0"
            ComboBox2.Value = 65
            ComboBox2.AddItem "10"
            ComboBox2.Value = 48
            ComboBox2.AddItem "20"
            ComboBox2.Value = 51
                      
      
          End Select
Select Case ComboBox1.ListIndex
                     
            
          Case 1
           
            ComboBox3.Clear
            ComboBox3.AddItem "cc"
            ComboBox3.Value = 70
            ComboBox3.AddItem "dd"
            ComboBox3.Value = 66
            
         Case 2
           
            ComboBox3.Clear
            ComboBox3.AddItem "dd"
            ComboBox3.Value = 74
       
            
            
      
          End Select
End Sub



Private Sub ComboBox2_CLICK()
Label1.Caption = "C" & (ComboBox2.Value) / 100

End Sub

Private Sub ComboBox3_click()
Label2.Caption = "K" & (ComboBox3.Value) / 100

End Sub



Private Sub UserForm_Initialize()
    ComboBox1.AddItem "0"
    ComboBox1.Value = 99
    ComboBox1.AddItem "10"
    ComboBox1.Value = 71
    ComboBox1.AddItem "20???"
    ComboBox1.Value = 65
ComboBox1.Style = fmStyleDropDownList

End Sub

when I change first combobox and the following combobox will show 99 in ComboBox2.Value = 99
and following calculate wil present 0 no matter which I change

can anyone help me to convert?

Or anyone can give me a list about different with vb6.0 & vba?


plz.....

Outcomes