VB2010 Telnet 接続


nobu  2012-05-17 08:57:21  No: 147593  IP: 192.*.*.*

以前にVisual Basic 掲示板にての下記のリンクのコードを
VB6にてテストして上手く動作しました。

telenetでデーター集信
http://madia.world.coocan.jp/cgi-bin/VBBBS/wwwlng.cgi?print+200401/04010087.txt

これをVB2010に変換しテストしています。
コネクトは出来て  "Please enter your call:"  が送られて来た後の
UserID送信が上手く行っていないようで、その後のデータが受け取れません。
どこに問題があるかご指摘いただき、解決策を教えていただければ幸いです。

Imports VB = Microsoft.VisualBasic

Friend Class Form1

  Inherits System.Windows.Forms.Form

  Private Const ab5k As String = "dxc.ab5k.net" 'K1TTT AR-Cluster
    Private Const User As String = "ja1test"
  Private Const Pass As String = ""
  Private Basp21 As Object
  Private fp As Short
  Private text1_fp As Short

    Dim ret As Integer
    Dim szData As Object
    Dim startTime As Single

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        text1_fp = 0
        Text1.Text = ""

        With Basp21
            ret = .Connect(ab5k, 23, 20)
            If ret <> 0 Then
                MsgBox("接続タイムアウト等エラ−", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, " TELNET")
                Exit Sub
            End If

            ' Login処理
            Do
                ' 受信待ち
                Do
                    System.Windows.Forms.Application.DoEvents()
                    ret = .read(szData, 16)
                Loop While ret <> 0
                ret = .read(szData, 0)

                Text1.Text = Text1.Text & szData
                text1_fp = text1_fp + 1
                Text1.SelectionStart = Len(Text1.Text) + 1
                Text1.Focus()

                If InStr(Trim(szData), "Please enter your call:") > 0 Then
                    ' UserID送信
                    szData = User
                    ret = .Write(szData)

                    Text1.Text = Text1.Text & szData
                    text1_fp = text1_fp + 1
                    Text1.SelectionStart = Len(Text1.Text) + 1
                    Text1.Focus()

                    szData = Chr(&HD)
                    ret = .Write(szData)
                    szData = Chr(&HA)
                    ret = .Write(szData)
                End If

                startTime = VB.Timer()
                Do
                    System.Windows.Forms.Application.DoEvents()
                Loop While VB.Timer() - startTime < 0.1

            Loop While True

            ret = .Close
        End With

    End Sub

編集 削除