我想做一个客户端软件,可以在程序中填好搜索条件,然后点击搜索后直接用IE显示查询结果,功能类似阿里巴巴贸易通.

解决方案 »

  1.   

    '【VB声明】
    '  Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long'【说明】
    '  查找与指定文件关联在一起的程序的文件名'【返回值】
    '  Long,非零表示成功,零表示失败。会设置GetLastError'【参数表】
    '  hwnd -----------  Long,指定一个窗口的句柄,有时候,windows程序有必要在创建自己的主窗口前显示一个消息框'  lpOperation ----  String,指定字串“open”来打开lpFlie文档,或指定“Print”来打印它'  lpFile ---------  String,想用关联程序打印或打开一个程序名或文件名'  lpParameters ---  String,如lpszFlie是可执行文件,则这个字串包含传递给执行程序的参数'  lpDirectory ----  String,想使用的完整路径'  nShowCmd -------  Long,定义了如何显示启动程序的常数值。
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Label2_Click()    Call ShellExecute(Form1.hwnd, "open", "http://www.YourWebSite.com?User=XXX&Pwd=YYY", vbNullString, vbNullString, &H0)End Sub
      

  2.   

    请问大哥,如果想搜索指定的内容必须通过构造URL吗?请您用www.quyue.com这个网站或changbuy.com这个网站帮我举个例子好吗?
      

  3.   

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        Call ShellExecute(Form1.hwnd, "open", "http://changbuy.com/listzt.asp?id=1275", vbNullString, vbNullString, &H0)
    End Sub'其中id=1275即为参数部分
      

  4.   

    其实,你想实现的功能不难,关键是看你如何和asp或其他页面结合起来了,你可以调用webbrowse控件,VB自带,也可以用ASP的内置对象,比如:
        http://localhost/dd.asp?dd=vb的得到的值,在调用ASP内置对象进行传送和ASP通讯,
    response.redirect "dd.asp?dd="&trim(dd)&"'"
      

  5.   

    大哥,您们说的我大概明白,但我想知道可不可以通过用SQL语句构造?希望能与二位QQ讨论,我的QQ 98562
      

  6.   

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        ShellExecute 0, "open", "http://www.baidu.com/baidu?w=" & Text1.Text, 0, 0, 0
    End Sub
      

  7.   

    这样做还是不能满足我的要求,因为我不知道是不是通过构造URL来进行查询,还是通过SQL进行查询,麻烦您用www.changbuy.com这个站帮我做一下,做个样子让我看下谢谢您.
      

  8.   

    你可以在服务器端装一个IIS,然后自己在里面写一个Asp程序,然后再客户端调用就行了。
      

  9.   

    1、建个表,类型如下:
    ID   KEY    URL
    id是自动编号,KEY是关键字,URL是网址链接
    例如KEY="彩屏GSM手机",它在www.changbuy.com的链接地址是“http://www.changbuy.com/class.asp?lx=small&anid=32&nid=271”那么就是URL=“http://www.changbuy.com/class.asp?lx=small&anid=32&nid=271”
    2、输入关键字查询时候,就通过在表内查询,得到对应的URL,用上面几位老兄给的代码即可让其访问对应的网页
    例如输入“手机”
    SQL语句就是SELECT URL FROM URLTABLE WHERE  KEY LIKE "%手机%"
    你可以自己组合SQL语句,不要问我怎么写
    得到的URL如果有多条,可以列出来,让人选择,也可以就直接显示第一条,看你怎么做了。
    最后就是用上面的方法调IE即可
    下面的变量UrlStr要先将数据库里得到的链接赋值给它。Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        ShellExecute 0, "open", UrlStr, 0, 0, 0
    End Sub
      

  10.   

    http://www.changbuy.com/ 里的查询是Post方式,不能用这种方法的。
      

  11.   

    原来它的ASP是通过Request("classid")来读的,所以可以实现,以下是Form1.frmVERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "阿里巴巴在线查询"
       ClientHeight    =   2340
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   6210
       LinkTopic       =   "Form1"
       ScaleHeight     =   2340
       ScaleWidth      =   6210
       StartUpPosition =   3  'Windows Default
       Begin VB.TextBox Text1 
          Height          =   330
          Left            =   3990
          TabIndex        =   2
          Top             =   585
          Width           =   1575
       End
       Begin VB.ComboBox Combo1 
          Height          =   315
          ItemData        =   "Form1.frx":0000
          Left            =   1065
          List            =   "Form1.frx":0049
          TabIndex        =   1
          Text            =   "Combo1"
          Top             =   570
          Width           =   1950
       End
       Begin VB.CommandButton Command1 
          Caption         =   "查询"
          Height          =   450
          Left            =   4095
          TabIndex        =   0
          Top             =   1545
          Width           =   1215
       End
       Begin VB.Label Label2 
          Caption         =   "类型"
          Height          =   345
          Left            =   510
          TabIndex        =   4
          Top             =   615
          Width           =   630
       End
       Begin VB.Label Label1 
          Caption         =   "关键字"
          Height          =   345
          Left            =   3195
          TabIndex        =   3
          Top             =   645
          Width           =   630
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option ExplicitPrivate Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Private Const SW_SHOWNORMAL = 1Dim value As String
    Private Sub Command1_Click()
    Dim classid As Long    If Combo1.ListIndex = 0 Then
            classid = 0
        Else
            classid = Combo1.ListIndex + 31
        End If
        
        ShellExecute Me.hWnd, vbNullString, "http://www.changbuy.com/research.asp?anclassid=" & classid & "&searchkey=" & Text1.Text, vbNullString, vbNullString, SW_SHOWNORMAL
    End SubPrivate Sub Form_Load()
        Combo1.ListIndex = 0
    End Sub