|
It seems to me that there are 1000s of examples of how to read XML but very few on how to write XML - I have always used string concatenation but it can look a bit messy after a while.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
anyone can provide coding to print out the content of picturebox and richtext box using print dialog??any help is greatly appreciated... VB.NET
|
|
|
|
|
There is an interesting article called
Getting WYSIWYG Print Results from a .NET RichTextBox
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_RichTextBox.asp
It can be of great help.
Good work.
Bye.
|
|
|
|
|
Hello,
I am receiving data of 3 KB from a Linux Server in a VB client which connects to the server after every 2 minutes(using a timer).I am working in a LAN. I dump the data received in a text box after the .GetData method.The problem is that at an average of 40% of the time I am getting no/garbage data.The pattern is inconsistent i.e.it might receive correct data 5 times and then maybe fail 2 times.
Can anybody suggest a reason for this because I think I should receive data with more than 90% success in a small network.
Also,is it possible to assign more than 1 port in a server and and have the client connect to the different ports ? If yes, how ? I want to know this because I want to send/receive different data through different ports for different screens in the VB client application.
Thanks,
Dhrubo
Dhrubo
|
|
|
|
|
You might want to include some code samples from the server and client so we can see what your doing right/wrong.
RageInTheMachine9532
|
|
|
|
|
As requested by Dave Kreskowiak, I am including the code for the client and server so that somebody can suggest a solution.
Thanks for any help in advance.
Server:
void main(void)
{
create_socket();
bind_socket();
listen_client();
while(1)
{
connect_client();
send_data(); //receive_data();
shutdown(newSockfd,0);
close(newSockfd);
} /* Outer While closed */
return 0;
} /* end main */
void create_socket()
{
sockfd = socket(PF_INET,SOCK_STREAM,0);
if( sockfd < 0 )
{
printf("\nsocket can not be created !!!!");
return;
}
printf("\nsocket created,");
printf(" my descriptor:- %d",sockfd);
}
void bind_socket()
{
int ret_stat;
memset((char*) &servAddr,'\0', sizeof(servAddr));
servAddr.sin_family = PF_INET;
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
//servAddr.sin_port = htons(nTCPPort);//
servAddr.sin_port = htons(PORT_NO);
printf("\n Server Port Number = %d",servAddr.sin_port);
ret_stat = bind(sockfd, (struct sockaddr *)&servAddr,sizeof(servAddr));
if(ret_stat < 0)
{
printf("\nBind Error Status:%d",ret_stat);
exit(0);
}
printf("\nBind Success Status:%d",ret_stat);
return;
}
void listen_client ()
{
ret_stat = listen(sockfd,5);
if(ret_stat < 0)
{
printf("\nListen Error Status:%d",ret_stat);
exit(0);
}
printf("\nListen Success Status:%d",ret_stat);
return;
}
void connect_client(void)
{
printf("\nWaiting For Client To Connect : ");
len = sizeof(struct sockaddr);
newSockfd = accept(sockfd, (struct sockaddr *)&from, &len);
if(newSockfd < 0)
{
printf("\n accept request failed ");
}
printf("\n Client Connected ");
}
void send_data(void)
{
int send_stat;
int i,k=0;
char temp[12],buff[3000];
double decr_temp1 = 0.00,decr_temp2 = 0.00,decr_temp3 = 0.00,decr_temp4=0.00
float decr_temp5 = 0.00, decr_temp6 = 0.00;
int decr_temp7 = 0, decr_temp8 = 0;
short int decr_temp9 = 0,decr_temp10 = 0;
long int slab_no = 54790000;
//char temp1;
for (k=0;k<40;k++)
{
slab_no = slab_no + 1;
sprintf(slabdata[k].slabid,"%ld,",slab_no);
//0.--------------------------------------
if (k==0) strcpy(buff,slabdata[k].slabid);
else strcat(buff,slabdata[k].slabid);
// 1.---------------------------------------
slabdata[k].slabtemp = 900.00 - decr_temp1;
sprintf(temp,"%.2lf,",slabdata[k].slabtemp);
strcat(buff,temp);
decr_temp1 = decr_temp1 + 25.00;
//2.------------------------------------------------
slabdata[k].uptemp = 800.00 - decr_temp2;
sprintf(temp,"%.2lf,",slabdata[k].uptemp);
strcat(buff,temp);
.
.
. // for another 8 sets of data for total 10
}
send_stat = send(newSockfd,buff,sizeof(buff),0);
if (send_stat<0) //newly added
{
printf("\n Sending Error status :%d",send_stat);
exit(0);
}
printf("\n The length of Data that was sent is %d ",strlen(buff));
}
Client:
I am using the timer2 and the labels for testing the output and the will remove them later.
As a test, before the data arrival event I am disabling the timer and after the data has been received I enable ii because I thought the timer's priority was causing a problem.
-------
Dim mydata As String
Private Sub Form_Load()
Label8.Caption = Time
End Sub
Private Sub Timer1_Timer()
Label2.Caption = Time
If DateDiff("n", Format(TimeValue(Label8.Caption), "hh:mm:ss"), Format (Time, "hh:mm:ss")) >= 2 Then
Label8.Caption = Time
If Command1.Enabled = False Then Command1.Enabled = True
Command1_Click
End If
End Sub
Private Sub Command1_Click()
a = ""
If Winsock1.State <> sckClosed Then Winsock1.Close
Command1.Enabled = False
Timer1.Enabled = False
Winsock1.Connect "151.0.22.60",7500
End Sub
Private Sub Winsock1_Connect()
Timer1.Enabled = False
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim I As Integer
Static bkupbuff As String
Static counter As Integer
Label6.Caption = "Bytes Received : " & Winsock1.BytesReceived & " Bytes Total parameter : " & bytesTotal
On Error Resume Next
Winsock1.GetData a, vbString
Label4.Caption = "Length of a : " & Len(a)
If Len(a) < 2675 Then
Text1.Text = a
a1 = bkupbuff
Label9.Caption = "FAILED " & Len(Trim(Text1.Text))
a = ""
Else
Text1.Text = a
a1 = a 'for array purposes
bkupbuff = a 'for back up during error in data receive
a = ""
Label9.Caption = "SUCCESS " & Len(Trim(Text1.Text))
End If
Label5.Caption = Label5.Caption & " " & Str(counter): counter = counter + 1
Timer1.Enabled = True
Label8.Caption = Time
If Command2.Enabled = False Then Command2.Enabled = True
End Sub
Private Sub Timer2_Timer()
Label3.Caption = Time
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, _
ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error in socket : " + Description, vbOKOnly
End Sub
|
|
|
|
|
For the code below, I always get an empty string from "GetWindowText()" call, instead of getting the caption or title of the window.
Not sure, why am I getting that empty string?
Any help is appreciated.
Thanks.
===========================================
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessIDs(0))
If hProcess <> 0 Then
lRet = EnumProcessModules(hProcess, Modules(1), 200, cbNeeded2)
If cbNeeded2 > 500 Then
cbNeeded2 = 500
End If
If lRet <> 0 Then
For j = 1 To cbNeeded2
ModuleName = Space(MAX_PATH)
nSize = 500
x = GetWindowTextLength(hProcess)
str = Space$(x)
x = GetWindowText(hProcess, str, x)
tl_dt_GetPID = ProcessIDs(0)
lRet = CloseHandle(hProcess)
Exit Function
Next j
End If
End If
lRet = CloseHandle(hProcess)
End Function
|
|
|
|
|
See my reply in the other thread...
RageInTheMachine9532
|
|
|
|
|
I am attempting to stong name my first assembly. I found the Sn.exe utility,but can't seem to open it. When I try, it flashes on the screen and then disappears. The reference book I am using is very vague on how to use the utility. what am I doing wrong?
Please respond as soon as you can, I need to get the deployment done so I can get this application to my associates!
Thanks!
|
|
|
|
|
That's because SN is a command line utility. It doesn't have a window interface. Go to Start/Programs/Microsoft Visual Studio .NET (2002|2003)/Visual Studio .NET Tools and click on Visual Studio .NET (2002|2003) Command Prompt. Then type your SN command in there.
RageInTheMachine9532
|
|
|
|
|
Thanks!
Now I have another problem. My application references both Interop.Excel and Interop.VBIDE. after I assigned a strongname key pair to the (2) assemblies I wrote, I tried to build the solution, and got a build error saying that I needed to strong name these two assemblies. How do I do this?
Thanks Again!
|
|
|
|
|
Hi,
From VB, how can we kill a particular process, given the following scenario:
I see 2 applications, say cmd.exe in task manager and only one of them is of my concern, which I would like to kill from VB.
How can I distinguish this cmd.exe from the other. Note that I dont know which one to kill just by looking at it and also the process ID's change everytime I restart an application which generates this cmd.exe
Any help is appreciated.
Thanks.
|
|
|
|
|
In simple terms, you can't tell them apart unless there is a property that is unique to the process your trying to kill, like MAYBE its MainWindowTitle.
Use the Process class to get the list of processes. You can then use the Close method on the instance of Process to terminate that process.
RageInTheMachine9532
|
|
|
|
|
OK thanks,
The process cmd.exe is generated from VC++.
So I added the title bar from VC++ using
STARTUPINFO.lpTitle = "foo";
And from VB I used GetWindowText(), but it always gives back an empty string instead of the title(foo) of that process (cmd.exe).
I have defined GetWindowText() in VB as:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Any clue why am I getting empty string back and not the title?
|
|
|
|
|
Sorry, I though you were using VB.NET.
Wait a minute... If you have the VC source, why not just kill the process from the VC app? After all, when you launch the process you get a ProcessHandle back. You use that ProcessHandle with the TerminateProcess function and your done.
RageInTheMachine9532
|
|
|
|
|
Well, there are some software architectural problems and paths which needs to be followed and this killing process is a specific scenario. Thus I cannot kill from VC.
Hence I need to kill it from VB...(its a long story, but in short, cannot kill from VC).
Sorry for the confusion..
|
|
|
|
|
Well, I've got an old VB6 source that will show you how to enumerate all the windows on the Desktop or your current app. It will also demonstrate GetWindowText. You can use the information gathered in this source to add to your code. You can use the window handle that is returned for your command window so you use SendMessage and WM_CLOSE to get the CMD window to close itself.
Just drop me a note at dkreskowiak1@(kill the stuff in parenthesis)comcast.net and I can send you the Zip'd source.
RageInTheMachine9532
|
|
|
|
|
Hi
I don't know.. But I create a crystal report usign VS.NET Enterprise Edition and put into my project. But when I want to request the crystal report It's not appear. I don't know what I doing wrong. Anyone can help on that or give some advise.
Thanks
Johnny Lizardo
|
|
|
|
|
The following link will allow you to register and download a be beginers guide which I found usefull when starting out.
http://www.crystalreportsbook.com[^]
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Hi all
In my app i create modal dialog box
by call ShowDialog like here
...
dim res as DialogResult
res = dlg2.ShowDialog(Me)
//res always cancel
In properties of dlg2 i set AcceptButton and CancelButton to vary buttons on my form but when i press any of this one
i return in my code with same result res = Cancel
Is this studio bug???
Or i desperate silly???
And else
Which control i can use to be part my dialog on some frame.
Thanks
|
|
|
|
|
On your dialog form, check the OK and Cancel button's DialogResult properties and make sure that they are set to what you want them to. When these buttons are clicked they will copy their DiaglogResult properties to the Forms DialogResult, thereby getting passed back as the result of your ShowDialog call.
RageInTheMachine9532
|
|
|
|
|
I am developing a windows service which would check if a particular program is running and if not start the program as an application.
But I cant seem to able to get it.
I have used "Shell" but the service starts the program as a service running in the background and not as an application. How do I do that?
|
|
|
|
|
It's not working because the service is running on it's own desktop, not the one the user sees.
Currently, the .NET FCL does NOT support services that interact with the user desktop. You would have to P/Invoke the CreateProcess function to launch the app, but that would also require that the service runs under a user account and not the LocalSystem account.
RageInTheMachine9532
|
|
|
|
|
In my resize event i use Height to change the height of the object but i see that sometimes ScaleHeight is used. Why? What's the difference?
Grtz,
Guus
|
|
|
|
|
Use the Height, Width, Left, and Top properties for operations or calculations based on an object's total area, such as sizing or moving the object.
Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.
RageInTheMachine9532
|
|
|
|
|