以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  高级功能研发区  (http://www.weistock.com/bbs/list.asp?boardid=5)
----  登录身份验证的窗体编写范例  (http://www.weistock.com/bbs/dispbbs.asp?boardid=5&id=4887)

--  作者:admin
--  发布时间:2011/1/19 0:53:40
--  登录身份验证的窗体编写范例

 

 

 

下载地址 http://www.weistock.com/download/Logon.frm

导入方法:


窗体全部代码如下


LoginOk = 0 \'0未登录 1登录成功

Sub Logon_Load()
   Logon_OptionButton_Server1.Value = true
   Logon_TextBox_UserName.Text = Document.GetPrivateProfileString("MyID", "LogName", "", "C:\\HengFuSet.ini")
End Sub

Sub APPLICATION_VBAStart()
     logon.Show\'显示登录窗口
 End Sub

Sub Logon_CommandButtonOK_Click()
   Dim Server
   Dim Port
   Dim UserName
   Dim Password
  
   If Logon_OptionButton_Server1.Value = true Then
    Server = "192.168.1.88"
    Port = 55106
   End if
  
   UserName = Logon_TextBox_UserName.Text
   Password = Logon_TextBox_Password.Text
  
   Result = NetWork.UserValidate(Server,Port,UserName,Password) \'至金钻版服务器验证用户身份
  \' Result = 1
  
   if Result = 0 Then
      MsgBox "服务器连接失败,请确认网络连接是否正常"
   End if
  
   if Result = 1 then
   \'登录成功
    
 Logon.EndForm
 checkoutdenglu=1
 LoginOk = 1

   End if
  
   if result = 2 then
    MsgBox "用户名密码无效"
   End if
  
   if result = 3 then
    MsgBox "用户名重复登录"
   End if
  
   if result = 4 then
    MsgBox "用户名已过期"
   End if
  
   if result = 5 then
    MsgBox "服务器已满"
   End if
  
   call Document.WritePrivateProfileString("MyID", "LogName", Logon_TextBox_UserName.Text, "C:\\HengFuSet.ini")
  
End Sub

Sub Logon_CommandButton_Cancel_Click()
 Logon.EndForm
End Sub


 

[此贴子已经被作者于2011-1-19 9:22:38编辑过]

--  作者:deni977
--  发布时间:2020/8/9 7:24:21
--  
UserValidate验证成功,如何建立连接服务器 ?(希望能够VBA代码能够连接策略服务器,不需要通过工具栏那里连接)