|
Hi Christian,
Thanx for clearing up the platform independent stuff, I have been using VB for quite some time, and people critisize me for sticking with vb, but vb is quite a powerful language though.
The pcs have office installed on them, I will give the RegSvr32 a try, I didn't bother to look at it, as I have read that if you are using an installer, it will automatically register the dlls. Is there any other way (other than using COM, which I will have to register) to use Excel, Word and Outlook, or are including them in my project the only way?
Thanks again, you have saved me a lot of work!
|
|
|
|
|
Member 4247277 wrote: and people critisize me for sticking with vb, but vb is quite a powerful language though.
VB6 was crap. VB.NET and C# are largely interchangable. People assume that b/c C++ was better than VB6, C# is better than VB.NET and it's not true.
Member 4247277 wrote: I didn't bother to look at it, as I have read that if you are using an installer, it will automatically register the dlls.
You don't have any dlls that need registering, at least, not in the list you provided. I don't think so, anyhow. My next step would be to look at the event code in the form that blows up when made visible, and add message boxes to work out which call is causing the error. It will be code that uses one of these libraries. Once you know which library has an unregistered dll, you'll have a much better starting point.
Member 4247277 wrote: Is there any other way (other than using COM, which I will have to register) to use Excel, Word and Outlook, or are including them in my project the only way?
You can use the Microsoft Tools for Office, which with newer versions of office, connect directly through .NET without COM. But, if Office works on these PCs, the dlls are registered. Your interop dlls define the connection to come, they don't need registering.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks Cristian,
I have used messageboxes, thats how I came up with the questions providing where the errors occur.
The biggest problem that I have is this - I will guide you through what I did, so that you can see what has already been done.
<br />
'Global variables<br />
Private cls1Ref as New clsClassOne<br />
Private cls2Ref as New clsClassTwo<br />
Private cls3Ref as New clsclassThree<br />
Say, that clsClassOne is used to manipulate - add, edit, remove, get, etc - data from a SQL database, table name : tableOne; clsClassTwo is used to get data from a SQL database, table name : tableTwo; and clsClassThree sends email, creates new Word documents and makes graphs in a Excel sheet, all using the same database.
Now, if these global variables are the global variables of my main form, the form won't load, the class not registered error message is displayed; if I now make the global variables local to the methos that will use the variables, say I have three buttons, each with its own class reference :
<br />
'No Global variables<br />
'Only for the main form<br />
Private Sub Button1_Click(.....)<br />
dim cls1Ref as New clsClassOne<br />
cls1Ref.add(........)<br />
End Sub<br />
<br />
Private Sub Button2_Click(....)<br />
messageBox("Before Ref")<br />
dim cls2Ref as New clsClassTwo<br />
messageBox("After Ref")<br />
dim name as String = cls2Ref.get(.....) 'If the retrieved value is to be a string<br />
messageBox("After Retrieval")<br />
End Sub<br />
<br />
Private Sub Button3_Click(....)<br />
dim cls3Ref as New clsClassThree<br />
cls3Ref.sendMail(.......)<br />
End Sub<br />
OK, now, this is an example after I have made the global variables local, and added messageBoxes to catch where the error occurs.
Now, if this is to be in the main form, the main form will load successfully, if either button 1 or button 3 is clicked, the class not registered error will occur, but if button 2 is clicked, messageBox("Before Ref") will pop up, then messageBox("After Ref") will pop up, and then the program will crash, no error, nothing, so the obvious problem then lies at cls2Ref.get(.....).
Because of this, I now have made all the global variables that are assigned classes local, so now we use the same buttons with the same code, and the same thing happens as if the variables have stayed the same.
All classes and forms use any combination of the following dlls :
-Interop.Word
-Interop.Excel
-Interop.Outlook
-MySql.data
Some don't use the MySql.data at all, some uses only the MySql.data, and other don't use any at all.
At this current moment, all my global variables that are classes are local (as explained above)
The connection to my database works fine, as in my main form a username and password is typed in, which is validated right there on the spot, no seperate class is used for this, also, excel reports are being printed and emails are sent from the main form (only these that aren't accessed via a seperate class).
I really hope my explanation is sufficient and clear and that you have a good idea of what is happening.
I appreciate all your efforts a lot,
Rossouw
BTW : Your blog is excellent!!
|
|
|
|
|
I have tried to register my dll's, but I get the following message:
dll was loaded, but the DllRegisterServer entry point was not found.
This file can not be registered.
|
|
|
|
|
Still an issue with UserControls here, with inconsistent behavior of SuspendLayout and ResumeLayout .
My UserControl consists of 3 panels and 2 buttons .
Docking and anchoring is used to mimic consistent 'look and feel' despite the size of the control (primarily Width ).
A Menu Control is populated with numerous instances of the UserControl defined above. Using a loop, I am resizing all these controls to an appropriate Width which is dynamically generated.
To increase performance as well as usability, my intention was to call SuspendLayout, resize the control by increasing or decreasing the Width, then calling ResumeLayout(True) so that a user does not see redrawing on the screen.
Obviously, without SuspendLayout() and ResumeLayout(True) the user will see the controls redrawing, which is time consuming and very poor to see.
However, when SuspendLayout() is called and then the control's Width property is changed, after ResumeLayout(True), the control is never resized. The Width property shows that the control's Width should be what I set, but the control is visibly unchanged.
What's worse is this behavior is not duplicated on another UserControl which has a similar hierarchy of panels and buttons, using the exact same loop those controls resize visibly as intended.
On a side note, I have enabled Double Buffering on all controls for faster drawing, albeit with little to no visible effect on the resizing of these controls.
My secondary solution involved shadowing SuspendLayout() and ResumeLayout() to loop through all controls and force SuspendLayout on the controls children, but that proved problematic and the lack of hits on Google and MSDN on either shadowing or overloading / overriding the SuspendLayout and ResumeLayout methods proved ineffective.
If any of this is unclear, it is because I have not had to much coffee today, so I'll answer any unclear statements about my problem at hand.
Example coding:
Dim o As System.Windows.Forms.Control
Me.ControlMenuComboBox.Width = i
For Each o In _collection
o.SuspendLayout()
o.Width = i
o.ResumeLayout(True)
o.Update()
Next ' the controls in the above loop DO NOT resize visibly as intended, Width property shows value of variable i.
For Each o In Me.Controls
o.SuspendLayout()
o.Width = i
o.ResumeLayout()
Next ' the controls in the above loop resize visibly as intended, Width property shows value of variable i.
As I assume the following is important I cannot stress it enough; all controls show the Width property has been set to variable i, however I feel that SuspendLayout() is inconsistent between my UserControls.
|
|
|
|
|
Hi all,
I encountered a little problem, after I decided to tramsform a Sub in a Function (and made the name of the array involved in Function, as argument to pass to the Function as string).
Code (Note: Asterisks and Number Sign # are note part of code)---------
Public Function ReadField(ByVal NameArray As String, ByVal Field As Integer) As String
'Dim NameArray As String
# Dim LenString As UInteger = Len(NameArray(ComboBox1.SelectedIndex + 1))
StringWpt = "" : Index = 0 : CommaCounter = 0
Do Until CommaCounter = Field - 1
* If NameArray(ComboBox1.SelectedIndex + 1)(Index) = "," Then CommaCounter = CommaCounter + 1
Index = Index + 1
Loop
* If Index = Len(NameArray(ComboBox1.SelectedIndex + 1)) Then GoTo 10
Do Until NameArray(ComboBox1.SelectedIndex + 1)(Index) = ","
* StringWpt = StringWpt + NameArray(ComboBox1.SelectedIndex + 1)(Index)
Index = Index + 1 : If Index = LenString Then Exit Do
Loop
10: Return LTrim(StringWpt)
End Function
Logically, the code (when working as Sub) is correct and works fine .
The problem is that exactely like is written above, the Function generate 3 errors "Expression is not an array or a method, and cannot have an argument list" in the lines I signed with *, but strangely is not generated in the line I signed with #.
If I enable as code the comment-line immediately below the definition of Function, and re-define again NameArray, the 3 errors are substituted with a single Error: "'NameArray' is already declared as a parameter of this method".
Note: When working as Sub, I not used the Array-name as variable, but I used the effective name of Array.
Do I forgotten something or is not possible to pass an Array name as argument?
Thanks for help
Ignazio
modified on Wednesday, September 9, 2009 12:16 PM
|
|
|
|
|
You cannot use the contents of a String variable as a variable name.
I'd suggest rewriting the entire concept using collections of arrays, but, given the code sample you posted, I'm not sure if my explanation is going to make any sense to you at all. You're using VERY old BASIC concepts in VB.NET. I would HIGHLY suggest picking up a beginners book on VB.NET before continuing this project.
|
|
|
|
|
Thanks for reply Dave,
But I can accept only first part of your help.
For second part, I let you know that I decided to not use a collection of Arrays because rarely I need to use more than 1 Array and I found this solution the more convenient(and efficent)for me.
I understand what you want say, but I not agree with you when you write that latest concepts of VB.NET are better than older concepts of Basic.
Often old concepts of Basic are better and more efficent than latest.
It's not a case that Microsoft mantained the compatibility of "Old Basic" in VB.NET
And it's for these reasons that when possible (and convenient)I prefer to use the "OLD concepts".
I not uderstand where in the code you see something that remember to you "Very old concept of Basic".
If you refer to the GoTo instruction, do you really think that changing it the code is improved (or made more efficent)?
Ignazio
|
|
|
|
|
Hurricane3000 wrote: but I not agree with you when you write that latest concepts of VB.NET are better than older concepts of Basic.
Often old concepts of Basic are better and more efficent than latest.
Well, you should ponder this:
1 - A Microsoft team worked to clean up and improve VB, do you think you know better than them ?
2 - In fact MS wanted to stop VB users from being able to use old VB6 concepts completely, because they are that bad, however, a bunch of luddite MVPs howled about it and so they changed it at the last minute.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hurricane3000 wrote: but I not agree with you when you write that latest concepts of VB.NET are better than older concepts of Basic.
Considering your having problems with code written in the Dark Ages and could be far better resolved with modern OOP code, I think you're wrong.
You've got legacy concepts all over that code snippet you posted. From the colons to the Goto to the non-terminated If statements and then some, you've got legacy concepts written all over this.
I haven't used a Goto statement in, let's see..., oh! 9 years now.
The more you use the old concepts, the deeper the hole you're digging yourself. If you want to maintain an ancient relic of a skill set, go ahead. You're only limiting your own abilities to keep a job.
|
|
|
|
|
You are passing a string as a parameter. It will not behave as an array. You will need to pass the array as a method parameter. I would second Dave's recommendation to getting a book.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thanks for help,
I think I'will follow your guideline.
But I don't think will be necessary to buy and read a book.
Ignazio
modified on Wednesday, September 9, 2009 3:40 PM
|
|
|
|
|
d@nish is saying you need to purchase a book and read it.
That is what Dave said as well, in fact all replies are suggesting you need to learn vb.net.
|
|
|
|
|
I disagree with the others. Your code is perfect. It's a masterpiece of obsfucation. I'm sure when you're trying to maintain it, that the extra time you take will go right onto your hourly rate, and I'm sure that writing code this hard to read means that the client will never find anyone else willing to work on it.
Seriously, when professionals tell you that you need to update your skillset, your options are to accept their advice, or assume that everyone is an idiot except for you. People I've known who do the latter, tend to end up unemployed.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
I agree with you when say that my code is a masterpiece of obsfucation, but this is my "unwanted" style.
The advantage is that it is a "natural obsfucation".
I ensure that it works, and it is to selectively read fields contained in text-records (lines) stored in an Array. Fields (of each record) are separated by commas. The record is selected in a comboBox.
Absolutely it's not true that when professionals tell me that I need to update my skillset, my options are to accept their advice, or assume that everyone is an idiot except for me!
For me doesn't exist the second of yours options.
For me the possible options are 3: Accept, Consider, Not accept.
But in no case Not accept can means to consider others idiot, of course!
I find strange if you consider only the 2 options, you written.
Ignazio
|
|
|
|
|
Hurricane3000 wrote: For me the possible options are 3: Accept, Consider, Not accept.
Well, you need a reason to not accept. Either we're all stupid, or we're right.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If your last want be a question, I think that it will remains an "unaswered question" because yours is a "wrong question".
Boolean matematich says that for each element(bit) added to a binary word, possible combinations are doubled.
For example:
If a binary word have only 1 bit, possible combinatins are 2.
If a binary word have 4 bit, possible combinatins are 16.
If a binary word have 8 bit, possible combinatins are 256.
In your question you not specified the word "All" how many bits have.
If "All" have more than 1 element(bit), the minimum possibilities to consider are 4.
Example: 00,01,10,11 (not only 00 or 11).
More, if words are minimum 2, to these can be applied following operators:
And, Nand, Or, Nor, XOr, Not-XOr, with a lot of further possibilities.
|
|
|
|
|
Hi all,
I solved the problem simply changing the first line of code (definition of function)
Public Function ReadField(ByVal NameArray As String, ByVal Field As Integer) As String
With this one:
Public Function ReadField(ByRef NameArray() As String, ByVal Field As Integer) As String Thanks fo help
Ignazio
|
|
|
|
|
Hello All I am having a hard time sending some email attcahments i looked all over google and youtube and i this ways of doing it and thay dont work for me i click the button and it just sits thare and do noting i take out the attachment line and it sends me a email no problem
can any one help
Thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyMailMessage As New MailMessage
Try
MyMailMessage.From = New MailAddress("FromEmail@gmail.com", "To Display Name")
MyMailMessage.To.Add("ToEmail@hotmail.com")
MyMailMessage.Subject = ("Status for " & TextBox1.Text)
MyMailMessage.Body = ("System status for " & TextBox1.Text & " save and open with Excel")
MyMailMessage.Attachments.Add(New Attachment("C:\Data.xls"))
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("FromEmail@Gmail.com", "Password")
SMTP.Send(MyMailMessage)
MsgBox("msg sent")
Catch ex As Exception
and i also tryed it like this i see now it is pretty much the same thing
Dim Data As New Attachment("c:\date.xls")
MyMailMessage.Attachments.Add(Data)
Thanks in advnace every one
|
|
|
|
|
I'm using something like the code below and it works fine for me.
' Create the mail message
Dim mail As New MailMessage()
' Set the addresses
mail.From = New MailAddress("FromEmail@gmail.com")
mail.To.Add("ToEmail@hotmail.com")
' Set the content
mail.Subject = "The subject..."
mail.Body = "The message body..."
' Add an attachment
mail.Attachments.Add(New Attachment("Path to attachment"))
' Send the message
Dim smtp As New SmtpClient("smtp.gmail.com")
smtp.Credentials = New System.Net.NetworkCredential("username", "password")
smtp.EnableSsl = True
Try
smtp.Send(mail)
Catch e As Exception
......
Finally
mail.Dispose()
smtp = Nothing
End Try
Regards
Nuri Ismail
modified on Wednesday, September 9, 2009 11:55 AM
|
|
|
|
|
Still not working for me i take the attatchem line out and it send the mail i put it back then i get noting
This is what i put
Thanks Agine
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Mail As New MailMessage()
Mail.From = New MailAddress("FromMail@gmail.com", "Display Name")
Mail.To.Add("ToMail@hotmail.com")
Mail.Subject = "Status for " & TextBox1.Text
Mail.Body = "System status for " & TextBox1.Text & " save and open with Excel"
Mail.Attachments.Add(New Attachment("C:\Data.xls"))
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("FromMail@Gmail.com", "Password")
Try
SMTP.Send(Mail)
Catch ex As Exception
Finally
Mail.Dispose()
SMTP = Nothing
End Try
End Sub
|
|
|
|
|
Did you try to send the e-mail without setting the SMTP port to 587? I know that default one (25) is not the best because of security issues but on gmail Problems sending mail[^] page i found this:
If you tried configuring your SMTP server on port 465 (with SSL) and
port 587 (with TLS), but are still having trouble sending mail, try
configuring your SMTP to use port 25 (with SSL).
The size of the attachments could also be a problem:
Also note that with Gmail, you can send and receive messages up to 20
megabytes (MB) in size.
I think that your problem could be connected with the used port or with the attachment itself. You can check out the above link for another possible reasons.
Regards
Nuri Ismail
|
|
|
|
|
I try port 25 465 and 587 with and with out ssl and it still dod not work
i dont think the size of the file is a problem it is only 1k
|
|
|
|
|
i got it working now
i have inported this
Imports System.Net.Mail
and then i found on google a guy hade it like this
Imports System.Net.Mail
Imports System.Net.Mime
Imports System.ComponentModel
and it worked
Thanks for you help man
|
|
|
|
|
Hello, I'm wandering is it possible to read file bit by bit in visual basic ? I know how to ready byte by byte
If it is, please tell me how, or give me link to the page to read something
Thanks
|
|
|
|
|