|
Ummm...why not just keep another copy of the files somewhere? Then write an app that can compare the last modified times of the working copies to the stored copies and if they are different, copy the stored copy back out to the working copy?
RageInTheMachine9532
|
|
|
|
|
Well, I was trying to keep my program as stand alone as possible, so keeping another copy of the files would be good, but I'd rather do it the dumb way.
I'll have to try Chr(34) soon. Other than that, this is exactly what I wanted.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
|
|
|
|
|
i used the Chr(34) in the example i provided.
simply copy and paste the exact sub from my example afew posts ago, and test it out.
------------------------
Jordan.
III
|
|
|
|
|
The only problem I have is when I get lines like this in the output text file sub:
outFile.WriteLine("")
Naturally, the issue is with the quotation marks. If I could get that to look like this instead:
outFile.WriteLine("")
Then I wouldn't get any problems. Bear in mind that this is the product of your exact sub. In any case, it doesn't really matter, because the sub accomplishes exactly what I need it to; it gives me the code to copy smaller, more simple HTML files. Therefore, I don't think this will be an issue.
I hope not. Anyway, thanks again for your help.
As I sit here, I contemplate the last words of Socrates: "I drank what?".
|
|
|
|
|
Does anyone know how to save entries from a form to a file so they can be accessed for later viewing? I need to be able to pull the saved data back to the form it was saved from for later use. If anyone could help me with this I'd appreciate it.
Thanks,
ccotton333
|
|
|
|
|
If you are using a Windows Form, you could bind your "entries" (textboxes and other controls, I suppose) to a DataSet, and then use the WriteXML() and ReadXML() DataSet methods to serialize/deserialize it on a disk file.
|
|
|
|
|
I would just save toa text file. Then you could read from the file to restore the valus. It is easy. You need System.io an duse stream reader and stream writer.
I have a logon form which is check for a saved user name from a file at load. And on Enter I save the user name to this same file. That way the user name is remembered when the program is ended and then restarted.
Ex. ( sName4User is global variable,
Private Sub frmLogon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' This will retreive a user name from file if present.
' Opens a file stream for reading
Dim myFS As New FileStream("c:\winnt\Temp\User.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.None)
Dim myReader As New StreamReader(myFS) ' Assigning a reader
sName4User = myReader.ReadLine 'Retreives username
If Not sName4User Is Nothing Then
txtName.Text = sName4User
End If
myReader.Close()
End Sub
Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
'Storing username to file and closing if a username was entered
If txtName.Text <> "" Then
sName4User = txtName.Text
' Opens a file stream for reading
Dim myFS As New FileStream("C:\winnt\Temp\User.txt", FileMode.OpenOrCreate)
Dim myWriter As New StreamWriter(myFS) ' Assinging a reader
myWriter.WriteLine(sName4User) ' Storing to the file
myWriter.Close()
Me.DialogResult = DialogResult.OK
Else
txtName.Text = "Enter a user name"
txtName.Focus()
txtName.SelectAll()
End If
End Sub
|
|
|
|
|
I want a simple socket programming application in vb.net. Can any one of them help me out.
|
|
|
|
|
This might help u out..
http://www.eggheadcafe.com/articles/20020323.asp
http://www.developerfusion.com/show/1845/
|
|
|
|
|
Sorry, but I'm too lazy to copy and paste that in to the browser....
http://www.eggheadcafe.com/articles/20020323.asp[^]
http://www.developerfusion.com/show/1845/[^]
That's better!
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Is there such a thing as a copy constructor in VB.NET?
How do I copy a class? Do I have to copy the class data explicitly?
Thanks in advance
JP
Rugby League: The Greatest Game Of All.
|
|
|
|
|
PaleyX wrote:
How do I copy a class?
Yes, if the class supports the ICloneable interface, you can use the <object>.Clone() method to create a copy of the object. SUch as copying a Bitmap object:
Dim cloneBitmap As Bitmap = myBitmap.Clone(cloneRect, format)
RageInTheMachine9532
|
|
|
|
|
I have just written my first VB.Net application. It uses a custom control, which I put into a control library project, which is loaded from a subroutine. the application runs fine when I build it in .Net, but when I use a startup project to build an installer,then install the application and try to launce the application, I get an error that the custom control or one of its dependencies can't be found. I traced the dependency that is not being found to the mscorlib. The application and teh custom control both have the following references:
Interop.Excel (10)
Microsoft.Office.Core
stdole
System
system.Data
System.Drawing
System.Windows.Forms
System.XML
Interop.VBIDE
1) How can I correct the dependency not found problem? I read that "you should avoid loading assemblies at run time by means of code or manually add the dependent assemblies to your deployment project". How do I add the assembleis (and which ones) to the deployment project?
2) What is the Interop VBIDE?
2) How do I deal with the dependencies on Office and Excel object libraries in my deployment. I found a help file that says to exclude the dependencies on other products from the deployment project, and write launch condition to prevent installation if the dependent file is not found. How do I do that?
Please respond quickly, I am supposed to send this application out for testing this week!
Thanks!
|
|
|
|
|
Have you installed the .Net Framework on the target machine?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
I am attempting to write an image to a network stream and am experiencing dificulties.
I have tried something allong the lines of:
<br />
myImage.Save(myNetworkStream, System.Drawing.Imaging.ImageFormat.Bmp)<br />
This causes a exception:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll
Additional information: A generic error occurred in GDI+.
So I changed my code to:
<br />
Dim ms As New System.IO.MemoryStream()<br />
'' write the image to the memory stream<br />
myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)<br />
'' declare a byte array <br />
Dim b(ms.Length - 1) As Byte<br />
'' set the position within the memory stream<br />
ms.Position = 0<br />
'' read the memory stream into byte array<br />
ms.Read(b, 0, ms.Length)<br />
'' write the byte array into the network stream<br />
myNetworkStream.Write(b, 0, b.Length)<br />
Is there a better way? Can anyone see why the first method threw an exception?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
i have just purchased and installed (successfully the message said) visual basic.net standard 2003. I am unable to create a new project, add a new item or blank solution. In fact, anything to do with adding or new windows form it will generate an error saying it cannot perform this operation. Can anyone help, with this problem.
|
|
|
|
|
Supplying the EXACT error message would very much help to determine the problem.
RageInTheMachine9532
|
|
|
|
|
When creating XML is better to just use string concatenation or use the XML document and create it in that? How would I go about doing the second?
Thanks
Jon
Rugby League: The Greatest Game Of All.
|
|
|
|
|
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
|
|
|
|
|