|
I always use the first case. Does case 2 work? I tried your sample by setting
<Componentmodel.Defaultvalue(True)>... but this doesn't seem to work.
Tosch
|
|
|
|
|
I used the second code, but i didn't realize until your reply.
Yes, the 2nd code doesnt work if we change the value to 'true'
I googling to msdn and find this statement:
"A DefaultValueAttribute will not cause a member to be automatically initialized with the attribute's value. You must set the initial value in your code."
Private MyVar as Boolean = False
<DefaultValue(False)> _
Public Property MyProperty() As Boolean
Get
Return MyVar
End Get
Set
MyVar = Value
End Set
End Property
and it make me more confuse,what is the function of this <DefaultValue(False)>
|
|
|
|
|
Apparently, i missunderstanding what i read before.
componenmodel.defaultvalue is used for other purpose (designer).
thanks
|
|
|
|
|
You have the other responses also, but now there is the new VS2010 way;
Public Property theProperty as boolean = false
Thats it, all the other Get, Set and local private variable are all taken care of under the hood. [which you can still use if you want, or depending on scenario] The local private variable will be named _theProperty by default, and accessible by that name.
|
|
|
|
|
My program consist of a user interface and a separate class that handles the merging of data files. The class is called Merge and when it is done merging the data it raises the event MergeFinished . I declared the following delegates:
Dim WithEvents Merge As clsMerge 'Class that handles the merging of data
Delegate Sub MergeFinishedDelegate() 'MergeFinished Delegate
Private m_MergeFinishedDelegate As MergeFinishedDelegate
Now the sub that handles the MergeFinished event is as follows:
Private Sub MergeFinished() Handles Merge.MergeFinished
If Me.InvokeRequired Then
m_MergeFinishedDelegate = AddressOf Me.MergeFinished
Me.Invoke(m_MergeFinishedDelegate)
Else
Me.Enabled = True
Status.Text = "Merge Finished!"
If Settings.AutoSwitch Then
Dim newFrm As New frmGenerateReports
newFrm.Show()
newFrm.RecieveData(JBNArray)
Me.Close()
End If
End If
End Sub
However the Me.Invoke(m_MergeFinishedDelegate) has an error of "Input string was not in the correct format". This function has been working fine and now it doesn't. I haven't made any changes to this method so I don't know why it broke. Any suggestions?
EDIT: After stepping through the code, this is what I discovered. When the event is first raised, the IF part of the statement is run and the Me.Invoke code works fine. However, when the newFrm.Show() is called then the "Input string was not in the correct format" is thrown within the IDE. Why is the debugger jumping back to the IF part of the statement? And if I keep stepping through, it just loops (calls the invoke, goes the the ELSE statement, and once newFrm.Show() is called the "Input string was not..." is thrown again and the frmGenerateReports is never shown)
modified on Tuesday, April 27, 2010 8:04 PM
|
|
|
|
|
Hi,
I don't think the Me.Invoke line is causing the problem; what it does is cause a thread switch, so your breakpoint/single-stepping debugging techniques probably got confused. I would suggest you put one big try-catch inside sub MergeFinished() , which then shows the Exception.ToString() that is probably occuring. My guess is something actually goes wrong inside RecieveData()
|
|
|
|
|
I have an access table containing several records. Infact records of universities alongwith their fee structure.
The task is to sort out the universities according to a given range and display that list in VB 2008 form.
Has anybody got any reference regarding this?
|
|
|
|
|
This sounds like homework and this little "how-to" has been documented hundreds of thousands of times. All it takes is a little Googling: "vb.net get data from access[^]".
|
|
|
|
|
I have several group boxes on top of one another but the problem i am facing is their merging with each other. How can it be avoided?
|
|
|
|
|
What do you mean by merging with one another? they can't do that.
|
|
|
|
|
i am trying to make a working simple calculator in VB.
i have 4 errors that i just can not figure out to save my life. can anyone help
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace projectfinal
{
public partial class Calculator : Form
{
bool Plus = false;
bool Sub = false;
bool Multiply = false;
bool Divide = false;
bool equals = false;
public Calculator()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{ //clears textbox and starts new problem
if (equals)
{
textBox1.Text ="";
equals = false;
}
textBox1.Text = textBox1.Text + "1";
}
private void button2_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button2.Text = button2.Text + "2";
}
private void button3_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button3.Text = button3.Text + "3";
}
private void button4_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text = "";
equals = false;
button4.Text = button4.Text + "4";
}
}
private void button5_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button5.Text = button5.Text + "5";
}
private void button6_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button6.Text = button6.Text + "6";
}
private void button7_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button7.Text = button7.Text + "7";
}
private void button8_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button8.Text = button8.Text + "8";
}
private void button9_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text ="";
equals = false;
}
button9.Text = button9.Text + "9";
}
//dont want more than one decimal on the screen
private void buttonDecimal_Click(object sender, EventArgs e)
{
if (equals)
{
textBox1.Text = "";
equals = false;
}
if (buttonDecimal.Text.contains("."))
{
return;
}
else
{
buttonDecimal.Text.contains + ".";
}
}
//if already neg it will become pos
private void buttonNeg_Click(object sender, EventArgs e)
{
if (buttonNeg.Text.contain("-"))
{
textBox1.Text = textBox1.Text.Remove(0,1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}
private void buttonPlus_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Plus = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}
private void buttonEquals_Click(object sender, EventArgs e)
{
equals = true;
if(Plus)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
if (Multiply)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
if (Sub)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) - Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
if (Divide)
{
Decimal dec = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text); //1st and 2nd value
textBox1.Text = dec.ToString();
}
}
private void buttonSub_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Sub = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}
private void buttonDivide_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Divide = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}
private void buttonMultiply_Click(object sender, EventArgs e)
{
if(textBox1.Text=="")
{
return;
}
else
{
Multiply = true; //adding something
textBox1.Tag = textBox1.Text;//stores number
textBox1.Text = "";
}
}
private void buttonclear_Click(object sender, EventArgs e)
{
Plus= Sub = Multiply = Divide = false;
textBox1.Text = "";
textBox1.Tag ="";//clear stores number
}
}
}
|
|
|
|
|
Some suggestions:
1. Put your code between <pre></pre> tags for readability; use the "code block" button in this editor.
2. Tell us what the errors are, we cannot see the output of your compilation from here, nor can we guess what might be going wrong.
It's time for a new signature.
|
|
|
|
|
on top of what Richard said, don't enter that amount of code all at once; start with a subset and get that working; working more incrementally will save you lots of time, so you can learn while doing, and not repeat earlier mistakes. I compile and run every two minutes, and I don't add code when what I have isn't working already to some extent.
|
|
|
|
|
terrable wrote: i am trying to make a working simple calculator in VB
I think you're biggest problem is that the code you provided is actually C# and not VB
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Steven J Jowett wrote: I think you're biggest problem is that the code you provided is actually C# and not VB
We have a winner!
|
|
|
|
|
I want to know the meaning of the code
Obj_aCrc = Obj_aCrc + Val(CStr(Asc(Mid(strVal, Obj_i + 1, 1)) * (Obj_i Mod (5) + 1)))
Thanks
|
|
|
|
|
When you cross-post, you should remove the original question, otherwise you'll be flamed.
Anyway the answer's Here.[^]
|
|
|
|
|
Michel Godfroid wrote: When you cross-post, you should remove the original question, otherwise you'll be flamed.
Then he'd also be flamed, for removing a question that already has an answer. Anyway, he got the hint to post here, and he did.
Some days it's just impossible to avoid the bullets, I guess
I are Troll
|
|
|
|
|
skskhoukhita2010 wrote: I want to know the meaning of the code
It's a crc[^]-check.
Val returns the numerical content of a string
CStr does the same thing as the .ToString() method
Asc returns the ASCII value of a character
Mid returns a subsection of a string
Mod divides two numbers and returns the remainder
I are Troll
|
|
|
|
|
|
Hi,
I have worked email option in vb6.0.
Its only working for gmail smtp server.
I want to sent from my offical mail server...
Plz Help me...
This is code for ur knowldge...
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = txtUsername.Text
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = txtPass.Text
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = txtPort.Text
.Update
End With
'strbody = "Your Sample message "
With iMsg
Set .Configuration = iConf
.To = txtTO.Text
.CC = txtCC.Text
.BCC = txtBCC.Text
.From = txtUsername.Text
'.From = "<your mailid to be displayed as@gmail.com>"
.Subject = txtSUb.Text
.TextBody = txtBody.Text
.Send
MsgBox ("Sent")
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
Google is your friend, also there are lots of articles, go inspect the archives here.
And why VB6?
Such ancient hieroglyphs have long since been replaced with VB.NET, it is easier to do mail with that.
eg just use mailto: command.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
What is the point of answering the OP in such a fashion ? Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously. Some people have the unenviable task of maintaining legacy apps written in out of date languages. This has nothing to do with their skill as a programmer, or their value as a Code Project member, just a basic fact of life. The OP asked a genuine question (to which you obviously have no knowledge of the language he is using or the methods that he is trying to use ), he also showed us his code he working on, and explained his problem in terms anyone could understand. I realise that you are an accountant, and not a programmer, but if you go through your answers that you are providing on this forum, I feel that maybe until Code Project opens up an accounting Forum, you should stick to the lounge where your contributions are much more appreciated. I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
|
|
|
|
|
zimvbcoder wrote: Do you honestly think that your answer is going to help the OP, or CodeProject for that matter, with your reply, seriously.
If the OP goes and searches google / CP for the answer it has helped him.
zimvbcoder wrote: Some people have the unenviable task of maintaining legacy apps written in out of date languages.
True, but DD asked why he was using VB6. In my opinion a valid question. If the OP responds with 'it's a legacy program' then we can move on. But if he responds with 'it's the only thing I know for this new program' we can tell him not to use it and spend some time learning .NET since VB6 isn't supported anymore.
zimvbcoder wrote: I realise you are one of the more popular memebers here, and that I will probably be blazed by Liquid Nitrogen for even daring to express my opinion, but I really don't care. It is answers like this that are pushing me away from this Site, and it is unnecessary.
My supply of liquid Nitrogen has run out so... . Seriously tho I don't think your gonna get flamed for just expressing your opinion.
As to being pushed away from this site, why? If the answer(s) you get don't apply or answer the question ask for more explanation. If it was insulting vote appropriately (also if not insulting)
If the answer is truly so bad that you feel personally attacked go to 'site bugs / suggestions' and ask Chris to have a look at it.
|
|
|
|
|
Tom Deketelaere wrote: If the OP goes and searches google / CP for the answer it has helped him.
Yah, teach a man to make fire, or set a man to fire - it's always a dilemma
Tom Deketelaere wrote: True, but DD asked why he was using VB6. In my opinion a valid question.
I can understand where the sentiment is coming from; nearly every VB6-question has two or three answers stating that one should "move on", whilst the programmer rarely has a choice in the language being used.
Tom Deketelaere wrote: since VB6 isn't supported anymore.
It's no longer actively supported by Microsoft. The community however, is a somewhat different beast. I'd even support 16-bit Delphi apps if required
Tom Deketelaere wrote: If the answer is truly so bad
Some of our members talk/type with an enormous passion for this trade, and sometimes that gets confused with anger. The arguments are the best proof that they care about what they do
I are Troll
|
|
|
|