|
|
hi, i am making a program with vb.net and I have a problem. Because I want the program to be registered first. I made a form with the register and another one with the program. You first want to register from the register form and then you can use the program form. I made the startup as the program and i used the stream reader to read from a text file if the user registered the program. if the user registered then he can use the program. when he double click the program the second time he (if he registered) i want to show only the program not the registration form of the program because he already registered. How can i make this!! HELP ME PLS!!!
Adrian
|
|
|
|
|
Your registration form should NOT be your startup form. Your main application form should be. The first thing it does should be to check to see of the app is registered, if not, put up the registration form as a modal dialog (ShowDialog). When the registration form is closed, check again to see if the app is registered. What you do from this point on is up to you, but normally you would setup your application in either a "full functionality" mode or a "restricted mode", depending on the registration status.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Q.1) How can you enable/disable network adapters in VB6? Is their a registry setting I can edit or a function that can do this?
Q.2) How can I create a list in a VB project of all Network adapters(NICs) on my PC.
I have done dozens of google and microsoft searches and found nothing but dead ends. I greatly appriciate your help.
Thank you "The Code Project" community
|
|
|
|
|
The reason you didn't find any VB6 code to specifically do this is because, one, it's not something most people would do, and two, they wouldn't normally use VB6 to do it.
1) There is no registry setting that will do this. This must be done by using the Device Manangement API functions. Definately not for the faint of heart, or those weak in COM skills. If you want to take a look at what's involved, click here[^]. You've been warned...
2) You can do this using Windows Management Instrumentation to get a list of Win32_NetworkAdapter s. For more on using WMI, see here[^]. Oh yeah, you cannot use WMI to disable the network adapter(s)!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave,
I'm not sure if I can handel this job on my own, but I've got to get it done somehow so I'll have to learn it. Thanks for your help.
|
|
|
|
|
Oh! BTW, the Device Management functions will only work under an Administrator account...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Option Explicit
Dim Num1 As Variant
Dim Num2 As Variant
Dim Num3 As Variant
Dim Seed As Variant
Dim Answer As Variant
Dim Counter As Variant
Dim Total As Variant
Dim Percent As Variant
Dim Response As Variant
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdNext_Click()
Num1 = 0
Num2 = 0
Num1 = lblNum1 + Num1
Num2 = lblNum2 + Num2
Num3 = Num1 + Num2
TxtResponse = Response
Counter = 0
Total = 0
If (Response <> Num3) Then
lblMessage = ("Wrong")
Total = Total + 1
End If
If (Response = Num3) Then
lblMessage = ("Correct")
Counter = Counter + 1
Total = Total + 1
End If
lblNum1 = Int(Rnd * 11)
lblNum2 = Int(Rnd * 11)
TxtResponse.Text = Format("")
lblScore = ((Counter / Total) * 100)
End Sub
Private Sub Form_Load()
Randomize Seed
Randomize Timer
Num1 = Int(Rnd * 11)
Num2 = Int(Rnd * 11)
lblNum1 = Num1
lblNum2 = Num2
End Sub
----------------------------------------------------
In this code there is an equation using if statements. This equation always evaluates to either true or false. The if statement doesn't alternate depending on the answer that is returned by the user. Is there anyway to get the If statement working propperly?
|
|
|
|
|
Well, you're first problem is that you declared everything as Variant 's. This will only cause you problems since you have no type checking being done on any of your values. Change your Variants to use the correct types. Like Num1, Num2, Num3, should all be Long types.
Next, the if statements you have can, apparently, be combined into one statement. But you never said anything about what this program is supposed to do, so we're just guessing at what you mean by "make it work."
I'd love to rewrite this program from scratch, but it has all the earmarks of homework. But, here's your if statement re-written:
If (Response <> Num3) Then
' if condition is True, execute this block of code,
lblMessage = "Wrong"
Total = Total + 1
Else
' otherwise, execute this block of code.
lblMessage = "Correct"
Counter = Counter + 1
Total = Total + 1
End If
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the help with the long type.
I have tried and tried again incorporating the if statements into one statement. The statement still does not work.
-The program is designed to be a basic flashcard type addition program. Num1 and Num2 are random variables that are to be added together. Num3 is an incorporation of both Num1 and Num2 for ease of programming the if statement.
-The if statement is my big problem i need help with. It always returns a correct. If i change the code around, so the correct is first:
If (Response = Num3) Then
lblMessage="Correct"
Counter = Counter + 1
Total = Total + 1
Else
lblMessage = "Wrong"
Total = Total + 1
End If
The if statement always returns a correct answer and never a wrong one. I am new to VB and am not really sure how to make this work.
|
|
|
|
|
Well, in the interest of teaching, I'll rewrite your entire application. Now, if this is homework, don't even think of trying to turn this in. Your prof WILL KNOW you didn't write it! Especially if your next project gets turned in looking nothing like this one!
Option Explicit
Dim Num1 As Long
Dim Num2 As Long
Dim Total As Long
Dim TotalQuestions As Long
Dim CorrectAnswers As Long
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdNext_Click()
TotalQuestions = TotalQuestions + 1
If CLng(TxtResponse.Text) <> Total Then
lblMessage = "Wrong"
Else
lblMessage = "Correct"
CorrectAnswers = CorrectAnswers + 1
End If
TxtResponse.Text = ""
lblScore = (CorrectAnswers / TotalQuestions) * 100
End Sub
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub GenerateNewTest()
Num1 = int(Rnd * 11)
Num2 = int(Rnd * 11)
Total = Num1 + Num2
lblNum1 = Num1
lblNum2 = Num2
End Sub
This is still nowhere near correct coding practices, but you should get the general idea from this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the Help. I was able to get by program working from part of your code.
|
|
|
|
|
Anyone know where i can get some good help with a CR problem it is pretty advanced stuff.
James Kennelly
|
|
|
|
|
|
Ok you asked for it
This converts decimals to fractions for reporting but when you have a whole number with out a decimal it display X 1/1 behind it and i am trying to only display the whole number in that case. Good Luck
NumberVar Dec;
NumberVar Zeroes;
NumberVar Denom;
NumberVar Numerator;
NumberVar Whole;
NumberVar CommonDenom;
StringVar StringDec;
StringVar FinalNumerator;
StringVar FinalDenom;
StringVar Fraction;
//Initialize the Decimal.
Dec := CDbl ({PROPOSAL.HEIGHT});
//Convert the Integer to a String to retrieve the Decimal value.
StringDec := ToText (Dec - (Truncate (Dec)), 10);
//Remove the trailing zeroes and get the exponent.
If StringDec [12] <> "0" then
Zeroes := 10;
If StringDec [12] = "0" then
Zeroes := 9
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" then
Zeroes := 8
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" Then
Zeroes := 7
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" Then
Zeroes := 6
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" Then
Zeroes := 5
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" and
StringDec [7] = "0" Then
Zeroes := 4
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" and
StringDec [7] = "0" and
StringDec [6] = "0" Then
Zeroes := 3
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" and
StringDec [7] = "0" and
StringDec [6] = "0" and
StringDec [5] = "0" Then
Zeroes := 2
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" and
StringDec [7] = "0" and
StringDec [6] = "0" and
StringDec [5] = "0" and
StringDec [4] = "0" Then
Zeroes := 1
Else Zeroes := Zeroes;
If StringDec [12] = "0" and
StringDec [11] = "0" and
StringDec [10] = "0" and
StringDec [9] = "0" and
StringDec [8] = "0" and
StringDec [7] = "0" and
StringDec [6] = "0" and
StringDec [5] = "0" and
StringDec [4] = "0" and
StringDec [3] = "0" Then
Zeroes := 0
Else Zeroes := Zeroes;
//Initialize the Denominator and Numerator.
Denom := Expo (10,Zeroes);
Numerator := ToNumber (StringDec [3 to (Zeroes + 2)]);
//Calculate the lowest common Denominator and Numerator.
If Dec - Truncate (Dec) = 0 Then
(Numerator := 1;
Denom := 1;)
else If Remainder (Numerator, 1250) = 0 Then
(Numerator := Numerator / 1250;
Denom := Denom / 1250;)
else If Remainder (Numerator, 625) = 0 Then
(Numerator := Numerator / 625;
Denom := Denom / 625;)
else If Remainder (Numerator, 25) = 0 Then
(Numerator := Numerator / 25;
Denom := Denom / 25;)
else If Remainder (Numerator, 5) = 0 Then
(Numerator := Numerator / 5;
Denom := Denom / 5;)
else if Remainder (Numerator, 2) = 0 then
(Numerator := Numerator / 2;
Denom := Denom / 2);
//Calculate the final values for the Numerator and Denominator.
If Remainder (Denom, Numerator) = 0 Then
(FinalNumerator := ToText ((Numerator / Numerator), 0);
FinalDenom := ToText ((Denom / Numerator), 0))
else (FinalNumerator := ToText (Numerator, 0);
FinalDenom := ToText (Denom, 0));
//Build the Fraction
Whole := (Truncate (Dec));
If Whole = 0 Then
FinalNumerator + "/" + FinalDenom
else
ToText (Whole, 0) + " " + FinalNumerator + "/" + FinalDenom;
James Kennelly
|
|
|
|
|
alright, i may be oversimplifying this and might be way off base, so correct me if i'm wrong, but couldn't you just evaluate whether or not the FinalNumerator and FinalDenom are equal?
Whole := (Truncate (Dec));
If Whole = 0 Then
FinalNumerator + "/" + FinalDenom
else
if FinalNumerator = FinalDenom Then
Cstr(Whole)
else
ToText (Whole, 0) + " " + FinalNumerator + "/" + FinalDenom; i'm not a crystal scripting expert by any means, so if this doesn't make any sense i apologize.
-jim
|
|
|
|
|
Jim,
That works it does give me a .00 but I am working on types to try to remove it. I was trying to make it much harder than that.
Thank you
James Kennelly
|
|
|
|
|
I'm developing an application for recording and playback audio files. i'm using visual basic 6.0
One problem I came to realize is the size of the audio file is too large and it is better if the files are to be in compressed format to reduce the file size. I wana use Window Media Audio codec but I do not know how to make it.
I need help from anyone .
Thanks
Ndanya
|
|
|
|
|
Hi all
I am trying to do Application Sharing (Powerpoint) using VBA, For that i want to send what i am typing to my client system. I want to capture keypress or any of the key events. can anyone help me to achieve this.
|
|
|
|
|
What your doing is sharing a desktop. This has already been done by applications specific to the task, such WebEx (www.webex.com).
How you want to do it just isn't practical. You'll have severe problems managing focus on the client machines and posting mouse and keyboard events to the correct controls, which is made even more difficult by the limitation imposed by using VBA.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually i am broadcasting messages to clients when the events occurs in the server using UDP Multicast. I dont have any problem in doing this. The problem is i need to see what the server is typing . If it is not possible in VBA is it possible using VB
Thanks for your reply
|
|
|
|
|
You run into the exact same problem. But check into VNC libraries to do the screen sharing. This seems to be a rather common project. Keep in mind, if time is an issue, you might want to look into a commerical product that does the exact same thing. You're not writing anything that hasn't already been done many times.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave, Actually my project is Application Sharing. The Powerpoint file will be in UDP server which is using multicast IP and all the clients have their own copy in their local memory. When i start Slideshow in my server it must start in all the clients too. I have done these by passing messages to clients. Capturing the screen and sending is not a difficult task when the communication medium(wireless) differs it involves lots of bandwidth. So only sending messages of whats happening in the server is only option left for me, when the person in the server types something it should be sent to all the clients. "THERE IS NO ONE COPY OF FILE, EACH CLIENTS HAS ITS OWN COPY" So thats why i need to capture textbox events. Thanks for your reply.
|
|
|
|
|
I am newbie for Outlook programming.I have created one folder named 'Test' in Outlook calendar using vb.net.There are somany folders in calendar.I need to create an appointment in the 'Test' folder.How can i find the subfolder of the Outlook calendar using VB.NET.I need to loop through the Calendar folder..
Any help is appreciated
Thank you very much
|
|
|
|