|
本帖最后由 盗梦 于 2014-8-4 09:27 编辑
这是一个利用XmlHttp对象实现中英互译的功能。主要代码如下:
- Private Sub cmdTranfor_Click()
- On Error Resume Next
- Dim str As String
- str = Nz(Me.txtText)
- If str = "" Then
- Me.txtTranfor = ""
- Exit Sub
- End If
- Dim objXml As Object
- Set objXml = CreateObject("microsoft.xmlhttp")
- With objXml
- .Open "POST", "http://fanyi.youdao.com/translate", False
- .setrequestheader "content-TYPE", "application/x-www-form-urlencoded"
- .send "i=" & str & "&doctype=json"
- txtTranfor = Split(Split(.responsetext, "tgt"":""")(1), """}")(0)
- End With
- Set objXml = Nothing
- If Err > 0 Then MsgBox Err.Description
- End Sub
复制代码
源码文件已附上。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
评分
-
查看全部评分
|