winsock question
Results 1 to 7 of 7

Thread: winsock question

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Posts
    29

    Question winsock question

    i was wondering if anyone could help me out with how to get a winsock control onto a VB form? i have visual studio .NET and windows XP. thanks. (its for tcp not udp just in case that matters)
    Stay away from my friends, they\'re smooth operators lookin for a way in.

  2. #2
    Member
    Join Date
    Aug 2003
    Posts
    98
    I gave this some thought, but sorry I can't help. Just in case you can't get any answers here, there is a alt.winsock on usenet
    I hate this place, nothing works here, I\'ve been here for 7 years, the medication does\'nt work...

  3. #3
    Junior Member
    Join Date
    Aug 2003
    Posts
    29
    well ok. i finally gave up and called M$ myself and the guy told me that i had to code my own windows socket? does anybody know how to do this or should i call back also the code for the server and client are different could anyone help me put it together? thanks
    Stay away from my friends, they\'re smooth operators lookin for a way in.

  4. #4
    HeadShot Master N1nja Cybr1d's Avatar
    Join Date
    Jul 2003
    Location
    Boston, MA
    Posts
    1,836
    I hope this source code helps.

  5. #5
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    ok, do you know how to add components in Visual Basic? you should be able to right-click on the tools-bar then click on "Components"... You should then see a list of registered .OCX files on your computer. Look for the "Microsoft Winsock Control" or something like it, then enable and add the component to your form, then your winsock code should work- but make sure the new winsock component is the same name as in your code...
    yeah, I\'m gonna need that by friday...

  6. #6
    Junior Member
    Join Date
    Aug 2003
    Posts
    29
    thats for 6.0 im using .NET. thanks for the help though
    Stay away from my friends, they\'re smooth operators lookin for a way in.

  7. #7
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    sorry, i haven't play'd with the .net yet...
    HOW TO: Programmatically Add Controls to Windows Forms at Run Time by Using Visual Basic .NET
    The information in this article applies to:

    * Microsoft Visual Basic .NET (2002)
    * Microsoft .NET Framework SDK 1.0

    This article was previously published under Q308433
    For a Microsoft Visual C# .NET version of this article, see 319266.
    For a Microsoft Visual Basic 6.0 version of this article, see 190670.
    IN THIS TASK

    * SUMMARY
    *
    o Requirements
    o Create a Windows Forms Application
    o Customize Form and Control Properties
    o Add Controls to the Form
    o Verify that it Works
    * REFERENCES

    SUMMARY
    This step-by-step article demonstrates how to programmatically add and configure a few, commonly used controls within a Windows application. Event handling has been omitted from the sample code.

    The Microsoft .NET Framework Software Development Kit (SDK) provides many visual controls that you can use to build a Windows Forms application. You can add and configure controls at design time in Microsoft Visual Studio .NET, or you can add and configure controls programmatically at run time.

    back to the top
    Requirements
    This article assumes that you are familiar with the following topics:

    * Visual Basic syntax
    * Visual Studio .NET environment
    * Purpose of common Visual Basic controls

    back to the top
    Create a Windows Forms Application

    1. Start Visual Studio .NET, and create a new Visual Basic Windows Application project named WinControls. Form1 is added to the project by default.
    2. Double-click Form1 to create and view the Form1_Load event procedure.
    3. In the first line of Form1.vb, add a reference to the color namespace before the definition of the Form1 class as follows:

    Imports System.Drawing.Color


    4. Add private instance variables to the Form1 class to work with common Windows controls. The Form1 class starts as follows:

    Imports System.Drawing.Color
    Public Class Form1
    Inherits System.Windows.Forms.Form

    'Controls
    Private txtBox As New TextBox()
    Private btnAdd As New Button()
    Private lstBox As New ListBox()
    Private chkBox As New CheckBox()
    Private lblCount As New Label()


    back to the top
    Customize Form and Control Properties
    Tip: You can use the With command to perform a series of statements on a specified object without requalifying the object's name.

    1. Locate to the Form1_Load event procedure, and add the following code to the procedure to customize the appearance of the Form control:

    'Set up the form.
    With Me
    .MaximizeBox = False
    .MinimizeBox = False
    .BackColor = White
    .ForeColor = Black
    .Size = New System.Drawing.Size(155, 265)
    .Text = "Run-time Controls"
    .FormBorderStyle = FormBorderStyle.FixedDialog
    .StartPosition = FormStartPosition.CenterScreen
    End With


    2. Add the following code to the Form1_Load event procedure to customize the appearance of the Button control:

    'Format controls. Note: Controls inherit color from parent form.
    With Me.btnAdd
    .BackColor = Gray
    .Text = "Add"
    .Location = New System.Drawing.Point(90, 25)
    .Size() = New System.Drawing.Size(50, 25)
    End With


    3. Add the following code to customize the appearance of the TextBox control:

    With Me.txtBox
    .Text = "Text"
    .Location = New System.Drawing.Point(10, 25)
    .Size() = New System.Drawing.Size(70, 20)
    End With


    4. Add the following code to customize the appearance of the ListBox control:

    With Me.lstBox
    .Items.Add("One")
    .Items.Add("Two")
    .Items.Add("Three")
    .Items.Add("Four")
    .Sorted = True
    .Location = New System.Drawing.Point(10, 55)
    .Size() = New System.Drawing.Size(130, 95)
    End With


    5. Add the following code to customize the appearance of the CheckBox control:

    With Me.chkBox
    .Text = "Disable"
    .Location = New System.Drawing.Point(15, 190)
    .Size() = New System.Drawing.Size(110, 30)
    End With


    6. Add the following code to customize the appearance of the Label control:

    With Me.lblCount
    .Text = lstBox.Items.Count & " items"
    .Location = New System.Drawing.Point(55, 160)
    .Size() = New System.Drawing.Size(65, 15)
    End With


    back to the top
    Add Controls to the Form

    1. Add the following code to add each object to the Controls array of the form:

    'Add controls to the form.
    With Me.Controls
    .Add(btnAdd)
    .Add(txtBox)
    .Add(lstBox)
    .Add(chkBox)
    .Add(lblCount)
    End With


    2. Save the project.

    back to the top
    Verify that it Works
    To verify that the sample works, click Start on the Debug menu. Note that although the form and the controls appear, they currently do nothing because you have not written any event handlers.

    back to the top
    REFERENCES
    For more information about using controls programmatically, see the Windows Applications topic in the Visual Basic section of the Visual Studio .NET Online Help documentation.

    back to the top
    Last Reviewed: 1/30/2003
    Keywords: kbHOWTOmaster KB308433 kbAudDeveloper
    yeah, I\'m gonna need that by friday...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •