当前位置:编程学习 > VB >>

翻译软件没有输出

请教一下,我自己用VB做了一个翻译软件,可是现在那个软件在点击button后竟然没有输出。
我想了很久就是不知道问题出在哪里。请各位高手指教一下。

Option Explicit
Dim NationalCode, UnicodeToUtf8()
Public mydb As String, myint As Integer, mycd As String

Private Sub Form_Load()
Me.Text1.Text = ""
Me.Text2.Text = ""
Me.ListView1.ListItems.Clear

    Call linkdata '连接数据库
    Set rs = New ADODB.Recordset

Text1.Text = ""
    Dim National$(), Tem$
    Dim i&
    Tem = "Chinese Enlish Albanian Arabic Azerbaijani Irish Estonian Belarusian Bulgarian Icelandic Polish Farsi Boer " & _
          "Denish German Russian French Filipino Finnish Georgian Haitian Korean Dutch Galicisch Catalan Czech Serbo-Croat " & _
          "Latvian Lithuanian Romanian Maltese Malay Nagsman Norwegian Portuguese Japanese Swedish Vichtelepa Slovak Slovenian " & _
          "Swahili Thai Turkish Kymric Ukrainian Basque Spaish Hebrew Greek Hungarian Armenian Italisn Yiddish " & _
          "hindi urdu Indonesian Vietnamese"
    National = Split(Tem)
    Tem = "zh-CN en sq ar az ga et be bg is pl fa af da de ru fr tl fi ka ht ko nl gl ca cs hr lv lt ro mt ms mk no pt ja sv sr sk sl " & _
          "sw th tr cy uk eu es iw el hu hy it yi hi ur id vi"
    NationalCode = Split(Tem)
    For i = LBound(National) To UBound(National)
        Combo1.AddItem National(i)
        Combo2.AddItem National(i)
    Next i
    Combo1.ListIndex = 0
    Combo2.ListIndex = 1
    Text1.Text = "中国"
    
    End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
rs.Close
cnn.Close

End Sub

Private Sub ListView1_Click()
On Error Resume Next
    mysql = "select * from " & mydb & " where ID =" & Left(ListView1.SelectedItem, 7)
    rs.Open mysql, cnn, adOpenKeyset, adLockOptimistic
    Text1.Text = rs.Fields(1)
    Text2.Text = rs.Fields(2)
    myint = rs.Fields(0)
    rs.Close

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next
    Select Case Button.Key
      Case "Google" 'Google Translate
            Me.ListView1.ListItems.Clear
            Dim SourceURL
            Dim ReturnCode
            Dim Voice
            Dim PostData
        If Len(Text1.Text) < 220 Then
            SourceURL = "http://translate.google.com/translate_a/t?client=t&text=" & _
                      UnicodeToUtf8(Text1.Text) & "&hl=zh-CN&sl=" & NationalCode(Combo1.ListIndex) & _
                      "&tl=" & NationalCode(Combo2.ListIndex) & "&pc=0&prev=btn"
            ReturnCode = RemoveChr(GetXmlHttp(SourceURL), "GET")
            If Combo2.ListIndex <> 56 And Text2.Text <> "" And Len(Text1.Text) < 34 Then
                Voice.URL = "http://translate.google.com/translate_tts?q=" & Replace(ReturnCode, " ", "%20") & "&tl=en"
            End If
        Else
            SourceURL = "http://translate.google.com/"
            PostData = "js=y&prev=_t&hl=zh-CN&ie=UTF-8&layout=1&eotf=1&text=" & UnicodeToUtf8(Text1.Text) & _
                      "&file=&sl=" & NationalCode(Combo1.ListIndex) & "&tl=" & NationalCode(Combo2.ListIndex)
            ReturnCode = RemoveChr(RemoveHeadTail(PostXmlHttp(SourceURL, PostData), "name=gtrans value=""", """><div id=sug_exp>"), "POST")
            End If
      
     
               
            Case "exit" '退出
        Unload Me
        
      Case "trans" '翻译
        Me.ListView1.ListItems.Clear
        Dim i, j
        Dim ks, bd, st3
        Dim yy As String
        Dim st As String, st1 As String, st2 As String, X As Integer
        If mydb = "ctom" Then
            yy = "Chinese"
            st = Trim(Text1.Text)
            If Len(st) >= 1 Then
                X = 0
                For i = Len(st) - X To 1 Step -1
                    st1 = Left(st, i)
                    mysql = "select * from " & mydb & " where " & yy & " = '" & st1 & "'"
                    rs.Open mysql, cnn, adOpenKeyset, adLockOptimistic
                    
                    If rs.RecordCount >= 1 Then
                         st2 = st2 & rs.Fields(2)
                         Text2.Text = st2
                        ListView1.ListItems.Add , , Format(rs.Fields(0), "0000000") & "." & rs.Fields(1)
                        X = i
                        i = Len(st) - X + 1
                        st = Right(st, Len(st) - X)
                        
                    Else
                        If Len(st1) = 1 Then
                                    st2 = st2 & st1
                                    Text2.Text = st2
                            X = i
                            i = Len(st) - X + 1
                            st = Right(st, Len(st) - X)
                        Else
                        End If
                    End If
                    rs.Close
                
                Next i
                If Trim(Text2.Text) = Trim(Text1.Text) Then
                  MsgBox "Have no find.", vbInformation, ""
                Else
                End If
                

            Else
                If mydb = "ctom" Then
                    MsgBox "Please importation Chinese into TEXT1.", vbInformation, ""
                Else
                    MsgBox "Please importation Malaysia into TEXT1.", vbInformation, ""
                End If
            End If
        Else
            yy = "Malaysia"
            st = Trim(Text1.Text) & " "
            For i = 1 To Len(st)
              st1 = Mid(st, i, 1)
              Select Case Asc(st1)
              Case 48 To 57, 65 To 90, 97 To 122
              st2 = st2 & st1
              Case Else
              st2 = st2 & st1 & " "
              End Select
            Next i
            st = st2
            st1 = ""
            st2 = ""
            
            If Len(st) >= 1 Then
                ks = 1
                For i = 1 To Len(st)
                   For j = i To Len(st)
                     st1 = Mid(st, j, 1)
                     
                     If st1 = " " Then
                        st2 = Trim(Mid(st, ks, j - i + 1))
                        bd = Right(st2, 1)
                        Select Case Asc(bd)
                          Case 48 To 57, 65 To 90, 97 To 122
                            '翻译
                            mysql = "select * from " & mydb & " where " & yy & " = '" & st2 & "'"
                            rs.Open mysql, cnn, adOpenKeyset, adLockOptimistic
        
                            If rs.RecordCount >= 1 Then
                                 st3 = st3 & rs.Fields(2)
                                 Text2.Text = st3
                                 ListView1.ListItems.Add , , Format(rs.Fields(0), "0000000") & "." & rs.Fields(1)
                            Else
                                 st3 = st3 & st2
                                 Text2.Text = st3
                            End If
                            rs.Close
                            
                            
                          Case Else
                            st2 = Left(st2, Len(st2) - 1)
                            '翻译
                            mysql = "select * from " & mydb & " where " & yy & " = '" & st2 & "'"
                            rs.Open mysql, cnn, adOpenKeyset, adLockOptimistic

                            If rs.RecordCount >= 1 Then
                                 st3 = st3 & rs.Fields(2) & bd
                                 Text2.Text = st3
                                 ListView1.ListItems.Add , , Format(rs.Fields(0), "0000000") & "." & rs.Fields(1)
                            Else
                                 st3 = st3 & st2 & bd
                                 Text2.Text = st3
                            End If
                            rs.Close

                        End Select
                        
                        i = j + 1
                        ks = j + 1
                        Exit For
                        
                     Else
                     
                     End If
                   Next j
                Next i
                
            st1 = ""
            st2 = ""
            st = Trim(Text1.Text) & " "
            For i = 1 To Len(st)
              st1 = Mid(st, i, 1)
              If st1 = " " Then
              Else
              st2 = st2 & st1
              End If
            Next i
            st = st2
                
                If Trim(Text2.Text) = Trim(st) Then
                  MsgBox "Have no find.", vbInformation, ""
                Else
                End If

            Else
                If mydb = "ctom" Then
                    MsgBox "Please importation Chinese into TEXT1.", vbInformation, ""
                Else
                    MsgBox "Please importation Malaysia into TEXT1.", vbInformation, ""
                End If
            End If
            
            
            
            
            
        End If
      
      Case Else
    End Select
      
End Sub

对不起,可能内容有些多。 --------------------编程问答-------------------- 代码太多了。你应该下断点,学会调试,看看哪里有问题。
补充:VB ,  VBA
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,