2013-02-16 2 views
0

나는 studentlogs ..라는 표가 있습니다. 그 위에 열 상태가 있습니다 .. 학생 기록에 레코드 삽입이 끝났을 때 ..상태 열만 사용할 수 있습니다. 3 개 그것이 값 중 하나를 1, 2, 3 ...다른 사람이 표의 열을 사용하는 경우

이제

.. 내가 레코드를 삽입 한 후처럼되고 그것을 원했다 ... 내가 일을합니다 ..

if status="1" then 
    CALL SENDSMS() 
ENDif` 
if status="2" then 
    msgbox("")ENDif 
if status="3" then 
    msgbox("") 

내가 그것을 어떻게 할 수 있습니다 내가 컬럼을 다룰 때? 감사합니다. :)

답변

-1

ElseIf 문을 많이 사용하지 않아도 될 가능성이있는 값이 하나 이상일 경우 CASE 문을 사용하십시오. 특정 열의 행 값을 가져 오려면 행 개체 바로 뒤에 괄호를 사용하고 ColumnName 또는 ColumnIndex 속성을 지정하여 값을 가져옵니다.

'declare local variables 
    Dim dr As DataRow 

    'create table 
    Dim studentLogs As New DataTable("StudentLogs") 

    'add columns 
    With studentLogs 
     .Columns.Add("Status", GetType(Integer)) 
     .Columns.Add("OtherCol1", GetType(String)) 
    End With 

    'add values 
    With studentLogs 
     dr = studentLogs.NewRow() 
     dr("Status") = 1 
     dr("OtherCol1") = "Joey" 
     studentLogs.Rows.Add(dr) 
    End With 

    For Each row As DataRow In studentLogs.Rows 
     Select Case row("Status") 
      Case 1 
       Call SENDSMS() 
      Case 2 
       MsgBox("2") 
       Exit For 
      Case 3 
       MsgBox("3") 
     End Select 
    Next 
관련 문제