hi,
ive got a question. im making an chat program with server and client using
vb 6. but now my problem is, i want to set a topic in each server.
i want to send the data from the server to all the clients connected, and
the client can see: ow, a topic, then /topic Bla bla bla
This is my code, maybe its less complicated.
Dim Data As String
Sock.GetData (Data)
If Mid(Data, 0, 6) = "/topic" Then
lblTopic.Captio n = Mid(Data, 7)
Exit Sub
End If
List1.AddItem (Data)
help is appreciated.
Dec 30 '06
11 11169
thankyou , now everything works fine!! :D
grtz,
313!
"Rick Rothstein (MVP - VB)" <ri************ @NOSPAMcomcast. netschreef in
bericht news:bM******** *************** *******@comcast .com...
> Sock.GetData (Data) List1.AddItem (Data)
You already have your answer to the question you asked; however, I wanted
to point something out about the above two lines of code from your
posting. Get out of the habit you apparently have of encasing arguments
for methods and, I will guess by extension, subroutine calls in
parentheses. Unlike other languages which **require** parentheses around
all arguments, VB doesn't. In the above statements, it won't cause any
problem; but there are cases where surrounding your arguments in
parentheses will cause an error to occur or, worse yet, no error will be
generated but incorrect results will be generated. You should only use
parentheses around arguments where they are required **by syntax**. For
arguments to methods (such as above), parentheses are never required; for
subroutines, they are required only when the CALL keyword is used to call
the subroutine.
The reason for my caution is that VB treats things in parentheses as
expressions to be evaluated (even if that thing is not really considered
an expression, such as a variable name). If your method or subroutine call
require two arguments, encasing both of them in one set of parentheses
will force an error to be generated as a comma separated list is not a
proper expression that VB can evaluate. The real problem comes with
arguments that are supposed to be passed ByRef (by reference)... a
parentheses-encased argument will force VB to pass the memory address of
the temporary memory location used to evaluate the expression and that is
what the subroutine will use to write back its ByRef argument to... which
means the original variable which was supposed to be updated by the
subroutine will not be (no error will be generated, but your results will
be incorrect). Here is a short example to show you what I mean. Paste the
following into new project's Form's code window...
Private Sub Form_Load()
Dim MyNumber As Double
' Set the value of MyNumber to a value, say 4
MyNumber = 4
' This next statement will generate the correct value
' of 16 (note that no parentheses are used).
SquareMe myNumber
MsgBox MyNumber)
' Reset the value of variable back to its original value
MyNumber = 4
' This next statement will generate the wrong value
' because it is surrounded in parentheses.
SquareMe (myNumber)
MsgBox MyNumber
End Sub
Sub SquareMe(ByRef X As Double)
X = X * X
End Sub
The SquareMe subroutine takes its passed value, multiplies it by itself
and then uses the fact that it was passed ByRef to send the updated value
back to the calling code by assigning the new value directly to the passed
argument. When no parentheses surround the argument, the variable is
updated correctly; but when the argument is surrounded by parentheses, the
variable does not get updated (the calculated variable was returned to the
temporary memory location where the "expression " was evaluated at before
being passed to the subroutine instead of the actual memory address of the
variable itself.
You will be doing yourself a big favor if you break the habit you have of
placing parentheses around arguments, now, before it becomes too ingrained
a habit to break later on.
Rick
argh, too fast happy :-(
a second connection to the server program, and it does not send any data.
for that to fix, i have to restart my server. ???
313. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
by: phil_gg04 |
last post by:
Dear Javascript Experts,
Opera seems to have different ideas about the visibility of Javascript
functions than other browsers. For example, if I have this code:
if (1==2) {
function invisible() {
alert("invisible() called");
}
}
|
by: laredotornado |
last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to
have my Javascript function execute from the BODY's "onload" method,
but if there is already an onload method defined, I would like mine to
run immediately after it. So in the code below, what JS would i need
to add to my "myfile.inc" page so that I could guarantee this behavior?
<!-- main page -->
<html>
<head>
<script type="text/javascript">
|
by: sushil |
last post by:
+1 #include<stdio.h>
+2 #include <stdlib.h>
+3 typedef struct
+4 {
+5 unsigned int PID;
+6 unsigned int CID;
+7 } T_ID;
+8
+9 typedef unsigned int (*T_HANDLER)(void);
+10
|
by: Olov Johansson |
last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7
and Konqueror 3.5) has support not only for standard function
definitions, function expressions (lambdas) and Function constructors
(these three I knew about), but also conditional function definitions,
as described in http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Defining_Functions
].
An example:
function fun() {
| |
by: Beta What |
last post by:
Hello,
I have a question about casting a function pointer. Say I want to make
a generic module (say some ADT implementation) that requires a function
pointer from the 'actual/other modules' that takes arguments of type
(void *) because the ADT must be able to deal with any type of data.
In my actual code, I will code the function to take arguments of their
real types, then when I pass this pointer through an interface
function, I...
|
by: f rom |
last post by:
----- Forwarded Message ----
From: Josiah Carlson <jcarlson@uci.edu>
To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org
Sent: Monday, December 4, 2006 10:03:28 PM
Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2
Ask on python-list@python.org .
- Josiah
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: alex |
last post by:
I am so confused with these three concept,who can explained it?thanks
so much?
e.g.
var f= new Function("x", "y", "return x * y");
function f(x,y){
return x*y
}
var f=function(x,y){
|
by: VK |
last post by:
I was getting this effect N times but each time I was in rush to just
make it work, and later I coudn't recall anymore what was the original
state I was working around. This time I nailed the bastard so posting
it before I forgot again...
By taking this minimum code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |