|
Wow! That's it. Your code works. Thanks a lot!
Thanks for the super fast response.
You've just saved me a lot of time.
I do have a few more questions.
1. How do I automate the process of creating the file1 and file2 at startup (load_event) so that I don't have to create them manually: at startup, check if file1 and file2 exists, if true, read from file1 and file2, if false, create file1 and file2. I know how to explain it but how do you say it in code?
2. How do I append logs for 30 days, on day 31, delete (or overwrite) log for day 1, on day 32 delete (or overwrite) log for day 2 and so on...
so that I always have logs for the last 30 days from today and at startup only load the latest(newest) log.
3. How do I put a calendar under a search button so when the search button is clicked, a calendar pops up and you pick a date and the log for file1 or file2 for that day gets loaded into the rtf box. I also need another button that lets you return to the current (last) log.
4. If I have a drop down menu on the form and collection items are: Up, Down, Left, Right, Front, Back and I have "Up" (or any other one) selected and the application gets closed, how do I save the setting so that when the form is loaded again, it shows the same selection it had before it was closed?
Thanks for your time.
|
|
|
|
|
Dear,
Is there anyone to give some suggestions for me? In my project, I would like to detect whether the mouse is tracking or not. I don't care where the mouse position.
First, I use Form_MouseMove function, but it can't sense when the mouse pointer arrives out of Form. Second, it can be sensed while using GetMousePos API, but it can't sense while the pointer arrive the boundary of the screen although the mouse is still jogging.
Can I sense that movement from the system? How can I write the code in VB 6.0?
Best Regards,
zawpai
|
|
|
|
|
I can't remember if this is going to apply to VB6 or not, but...
Handle the Form's MouseLeave event and you'll know when the mouse leaves your form. As for getting the mouse information after that, you'll probably have to run a Timer to fire off some code that gets the mouse position and compares it to the known coordinates of the edges of the screen. You'll probably need to use the GetMousePos function to get what you need.
You'll have to call the GetSystemMetrics[^] function to get the screen dimensions.
|
|
|
|
|
|
First, read this post[^].
I'm not looking through all that garbage to find the relevant code. Most of it's Java and the text for an agreement - hardly relevant to any VB.NET related questions.
Second, I have no idea what your question is...
|
|
|
|
|
Don't delete messages after someone has replied.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I'd like to export specific columns into certain positions in the textfile, can you show me how?
For example - loop through row, exporting into textfile:
column 1 ---> start on 1st line Position 20 in the text file (after 19 spaces)
column 2 ---> beginning of next line.
column 3 ---> (after 39 spaces), position 40.
__________________
I know how to set get the whole line, but how to get specific values from each row.
Here's what i have that extracts all (just a snippet of my code). Please help
For rowIndex = 1 To 50
colIndex = 1
If Not (CType(oWS.Cells(rowIndex, colIndex), Excel.Range)).Value2 Is Nothing Then
For colIndex = 1 To 15
If (CType(oXL.Cells(rowIndex, colIndex), Excel.Range)).Value2 Is Nothing Then
sWrtier.Write("" + vbTab)
Else
sWrtier.Write((CType(oXL.Cells(rowIndex, colIndex), Excel.Range)).Value2.ToString() + vbTab)
End If
Next
End If
|
|
|
|
|
What is the problem?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hi Paul,
I am trying to export each cell value as opposed to getting a whole row at a time, as they go to specific positions in the text file. Here's what i have now and i get
"Unable to cast COM object of type 'System.__ComObject' to class type 'System.Array'.
Error on line with--->" For r = 1 To UBound(arr, 1)". Can you help?
Sub MakeFixedWidth()<br />
<br />
Dim oXL As New Excel.Application<br />
Dim oWBK As Excel.Workbook = oXL.Workbooks.Open("\\nycapps01\DevFiles\SeamlessDev\Excel2Text\SampleInvoice8.xls")<br />
Dim oWS As Excel.Worksheet = CType(oWBK.Worksheets(1), Excel.Worksheet)<br />
<br />
<br />
'Dim Sizes As Object<br />
Dim arr As Object<br />
Dim r As Long ', c As Long<br />
Dim fso As Object<br />
Dim ts As Object<br />
Dim TheLine As String<br />
'Dim TestStr As String<br />
<br />
Dim names As Object = Array.CreateInstance(GetType(Integer), 10, 8, 10, 8, 10, 8, 10, 8)<br />
<br />
'Sizes = Array(4, 2, 45)<br />
arr = oWBK.ActiveSheet.UsedRange<br />
<br />
fso = CreateObject("Scripting.FileSystemObject")<br />
ts = fso.CreateTextFile("c:\blah.txt", True)<br />
<br />
For r = 1 To UBound(arr, 1)<br />
TheLine = Space(51) ' your fixed-width output<br />
<br />
Mid(TheLine, 1, 10) = oWS.Cells(r, 1)<br />
Mid(TheLine, 11, 8) = oWS.Cells(r, 1)<br />
Mid(TheLine, 19, 10) = oWS.Cells(r, 1)<br />
Mid(TheLine, 29, 8) = oWS.Cells(r, 1)<br />
Mid(TheLine, 37, 10) = oWS.Cells(r, 1)<br />
Mid(TheLine, 47, 8) = oWS.Cells(r, 1)<br />
Mid(TheLine, 55, 10) = oWS.Cells(r, 1)<br />
Mid(TheLine, 65, 8) = oWS.Cells(r, 1)<br />
ts.WriteLine(TheLine)<br />
<br />
Next r<br />
<br />
ts.Close()<br />
<br />
ts = Nothing<br />
fso = Nothing<br />
<br />
MsgBox("Done")<br />
<br />
End Sub
|
|
|
|
|
So I am using ODBC to connect to my SQL server like such:
<br />
<br />
connection = "Provider=MSDASQL;" + "Driver={SQL Native Client};" + "Server=MYSERVER;" + "Database=MYDB;" + "UID=MYUSERNAME;" + "PWD=MYPASSWORD;" + Trusted_Connection=yes;"<br />
<br />
Try<br />
Using connection As New OdbcConnection(ConnectionString)<br />
Dim command As New OdbcCommand(queryString, connection)<br />
connection.Open()<br />
<br />
Dim reader As OdbcDataReader = command.ExecuteReader()<br />
<br />
While reader.Read()<br />
station_count = reader(0).ToString<br />
End While<br />
<br />
connection.Close()<br />
reader.Close()<br />
End Using<br />
Catch ex As Exception<br />
SQLERROR = True<br />
WriteErrorLog(ex.ToString)<br />
Exit Sub<br />
<br />
End Try<br />
This is causing me a problem within my application. I wrote it using a Domain Admin which has access to the server through my SQL user, but the application needs to be deployed on a machine with much lower permission.
My question is:
1. Should I rewrite the database connection using a different method instead of ODBC
2. Is there something I can do on the server to fix this?
Thanks!
Steve
|
|
|
|
|
Why are you using the Odbc library instead of the SqlServer (SqlConnection, SqlCommand, Sqlxxxx...) specific library?
Also, if you're using TrustedConnection, it means you're using the Windows account to login to SQL Server. Specifying a username and password with SSPI (Trusted Connection = True) is pointless since it won't be used. You either specify a username and password to use (SSPI off) SQL Servers authentication, or you don't specify them and turn SSPI on to use Windows Integrated security.
You can get the various connection strings for all kinds of databases and connection options from ConnectionStrings.com[^]. There is also a small reference guide on the SQL Server connection strings here[^].
|
|
|
|
|
If I create a small custom class:
<br />
Public Class XMLNode1<br />
Private xmlHeader As String<br />
Private xmlValue As String<br />
<br />
Public Sub New()<br />
xmlHeader = Nothing<br />
xmlValue = Nothing<br />
End Sub<br />
Public Sub New(ByVal head As String, ByVal val As String)<br />
Me.propHead = head<br />
Me.propVal = val<br />
End Sub<br />
<br />
Public Property propHead()<br />
Get<br />
Return xmlHeader<br />
End Get<br />
Set(ByVal value)<br />
xmlHeader = value.ToString<br />
End Set<br />
End Property<br />
Public Property propVal()<br />
Get<br />
Return xmlValue<br />
End Get<br />
Set(ByVal value)<br />
xmlValue = value.ToString<br />
End Set<br />
End Property<br />
<br />
<br />
End Class<br />
<br />
How should i go about writing a disposal method for it?
Also, my idea of disposing a class is releasing all th eobject that class uses...Is that correct?
Please help
|
|
|
|
|
For this little class, you don't need to implement IDisposable.
You would normally implement IDisposable when your class holds onto unmanaged resources or holds onto other objects that require calling Dispose on them.
Read...[^]
|
|
|
|
|
I do have another class that uses an arraylist,xml reader, sql adapter, and sql connection.
I read about including a dispose method , but im not sure how to implement this. I guess i could just call each objects dispose method, but im curious as to add the disposal methods to my class.
|
|
|
|
|
As Dave mentioned, you generally don't need to implement IDisposable unless your class maintains unmanaged resources directly. However, if you are managing the lifetime of other managed resources that implement IDisposable you should also implement IDisposable yourself.
Take a look at this article[^] for more information.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]<</div>
|
|
|
|
|
Hello there!
I'm working with VB6 ( argh! I have no option) and I have a small problem,
My application has 6 forms and the main form posses 7 collections.
And the whole operation needs to work with those 7 collections (adding, deleting, counting and so on) in any Form.
My problem is: how to make those 7 collections Public or "Global"?
Ps.: I could do it in VB.Net but the current DLL's does not support .Net Framework yet.
Thanks in advance.
With Regards, Suguimoto
|
|
|
|
|
suguimoto wrote: orking with VB6 ( argh! I have no option)
Bummer. VB6 has been so dead for so long.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
IIRC, make the stuff Public in a Module.
But, IIRC, if you're thinking of doing this, you really need to rethink your data model/app design.
|
|
|
|
|
Actually I'm reading from a CSV file, putting into collections (like data base).
I believe that working with collections is the best way, instead of reading the CSV file everytime that the app needs to fill a listview ou delete a value.
At the moment I gave up on collections, and I'm reading the csv all the time. =/
Thanks anyway
|
|
|
|
|
Actually, I was referring to making everything "global"...
|
|
|
|
|
|
Just because you can do it, doesn't mean you should do it...
|
|
|
|
|
Hi,
how can i get the reference of existing(opened) form and manipulate its control properties like text,visbale etc on other form or within module? by doing new myForm does give reference of new instance rather existing one. Also, is there some different method to get instance in case of MDI application?
Would be greatful if I get some urgent response.
|
|
|
|
|
You've got a very bad design going.
You would have to pass these methods references to the forms that they would manipulate.
But, by doing so, you're completely trashing any and all concepts related to OOP and encapsulation of functionality.
No module should ever care about anything that is outside of its scope. Meaning, a method in a module shouldn't care that a form is using it. It shouldn't care about, nor use, the controls on any forms.
Forms should not be manipluating controls on other forms. Your forms should be exposing methods, and using other means, to tell themselves what to do to manipulate their own controls. This means your data model must support subscribers to events that you create, telling those subscribers that the data has changed. It's up to the subscribers to modify themselves in response to changes in the data.
|
|
|
|
|
I have a DatagridViewTextboxColumn. I allow word wrapping. When I am writting into the textbox, at run time, I would like to datagridview row height size to grow accordingly.
Here is my code:
Private Sub dgvDetail_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDetail.CellEndEdit
RemoveHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
EditingControl = Nothing
End Sub
Private Sub dgvDetail_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvDetail.EditingControlShowing
EditingControl = CType(e.Control, DataGridViewTextBoxEditingControl)
AddHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
End Sub
Private Sub editingControl_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
EditingControl.EditingControlDataGridView.AutoResizeRows()
End Sub
Please help
Shay Noy
|
|
|
|
|