|
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
|
|
|
|
|
hi
i am new to this vb.net, so i would like some help from the gurus of vb.net, how to adjust Brightness, contrast, satureation an image in picturebox using the trackbar....
lots of thanks in advance...
|
|
|
|
|
I want an algorithm implemented using vb to compare two voice samples for the similarity.I heard about the similarity based retrieval algorithms but dont have an idea how to implement. Please help me to get the source code or at least how to do it in VB.
Jay
|
|
|
|
|
I would imagine that any algorithm you find is going to be computationally expensive enough that it should be done in C++.
This is a pretty specific question, I'd suggest looking for more specific places to find answers. I doubt very much that anyone has done this in VB, so search for code/algorithms generally. You won't find VB code to do this online, and if I found some, I would not trust it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
here's a couple of places to start you off...
ShakyVoice - voice stress analysis tool
By Vladimir Ralev
http://www.codeproject.com/netcf/ShakyVoice.asp
http://unix.freshmeat.net/projects/liarliar/
LiarLiar - voice stress analysis tool
|
|
|
|
|
I want to get a voice sample digitized using the sound card and to save it as a wave file.I'm very thankful if any body can give me an idea how to do it using VB6.
Jay
|
|
|
|
|
To be able to digitize sound using VB 6, the simplest way to use is develop a program using simple visual basic functions. In windows environment, there is one library function "winmm.dll".
What you need to do is to include this library in your application and apply the mciSendString function with its parameters clearly defined. Then u can start writing the code for recording and saving the audio file.
for more information you can contact me or visit this site:
www.planet-source-code.com
Thank you
|
|
|
|
|
Hi,
How can i access the dynamically added textboxes ?
I tryed with Session , database but i couldnt....... When i used Cookies i couldnt retrive the prop. of textbox but i got only the date and time of creation.
Thanks in advance
|
|
|
|
|
You need to create the textboxes very early in the page lifecycle ( before PageLoad, basically ), so they are there when the viewstate is loaded. They need to have the same ID's and be in the same place every time. Then if you want to access their properties later, you can search for them by ID, or you can store them as you create them, or you can discover them by iterating through the table/datagrid/whatever that holds them.
If you find them and the text isn't there, then you've failed the first condition I pointed out, make them early and make them the same.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Thanks for ur kind reply.
I didnt get u sir.i am new to .net. I followed what u have suggested. i wrote it in Page_Init.I dont understand where i have went wrong. i am sending my pages plz check and tell .
1)Web3.aspx.vb
Imports System
Imports System.Net
Imports System.Net.Cookie
Imports System.Net.CookieCollection
Imports System.Net.CookieContainer
Public Class Web3
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents a11 As System.Web.UI.WebControls.TextBox
'Some more events for more textboxes
Protected WithEvents slno As System.Web.UI.WebControls.PlaceHolder
Protected WithEvents go1 As System.Web.UI.WebControls.Button
Protected WithEvents go As System.Web.UI.WebControls.Button
Protected WithEvents tt0 As System.Web.UI.HtmlControls.HtmlTable
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Dim z1, z2, z3, z4 As New TextBox
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim s1, s2, s4, s5, s7, s8,s10, s11 As Label
'Dim z, z1 As HtmlInputText
If Page.IsPostBack Then
s1 = New Label
s1.Text = " "
z1 = New TextBox
z1.EnableViewState = True
z1.Columns = "50"
s2 = New Label
s2.Text = ""
s4 = New Label
s4.Text = " "
z2 = New TextBox
z2.EnableViewState = True
z2.Columns = "50"
s5 = New Label
s5.Text = ""
s7 = New Label
s7.Text = " "
z3 = New TextBox
z3.Columns = "50"
s8 = New Label
s8.Text = ""
s10 = New Label
s10.Text = " "
z4 = New TextBox
z4.Columns = "50"
s11 = New Label
s11.Text = ""
slno.Controls.Add(s1)
slno.Controls.Add(z1)
slno.Controls.Add(s2)
slno.Controls.Add(s4)
slno.Controls.Add(z2)
slno.Controls.Add(s5)
slno.Controls.Add(s7)
' slno.Controls.Add(z3)
slno.Controls.Add(s8)
slno.Controls.Add(s10)
' slno.Controls.Add(z4)
slno.Controls.Add(s11)
'Response.Cookies("v").Value = z.Value
'Response.Cookies("v").Value = DateTime.Now.AddDays(1)
Session("t") = z1.Text
Session("t1") = z2.Text
'Session("t") = ViewState("z2")
'Session("t2") = CType(ViewState(z3.text),String)
End If
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub go1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles go1.Click
Dim s1, s2, s4, s5, s7, s8, s10, s11 As Label
If Page.IsPostBack Then
s1 = New Label
s1.Text = " "
z1 = New TextBox
z1.EnableViewState = True
z1.Columns = "50"
s2 = New Label
s2.Text = ""
s4 = New Label
s4.Text = " "
z2 = New TextBox
z2.EnableViewState = True
z2.Columns = "50"
s5 = New Label
s5.Text = ""
s7 = New Label
s7.Text = " "
z3 = New TextBox
z3.Columns = "50"
s8 = New Label
s8.Text = ""
s10 = New Label
s10.Text = " "
z4 = New TextBox
z4.Columns = "50"
s11 = New Label
s11.Text = ""
slno.Controls.Add(s1)
slno.Controls.Add(z1)
slno.Controls.Add(s2)
slno.Controls.Add(s4)
slno.Controls.Add(z2)
slno.Controls.Add(s5)
slno.Controls.Add(s7)
' slno.Controls.Add(z3)
slno.Controls.Add(s8)
slno.Controls.Add(s10)
' slno.Controls.Add(z4)
slno.Controls.Add(s11)
'Response.Cookies("v").Value = z1.Value
'Response.Cookies("v").Value = DateTime.Now.AddDays(1)
End If
Session("t2") = z3.Text
End Sub
Private Sub go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles go.Click
Response.Cookies("us").Value = a11.Text
Response.Cookies("us").Value = DateTime.Now.AddDays(1)
Response.Redirect("web4.aspx")
End Sub
Private Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DataBinding
End Sub
End Class
2)Web4.aspx.vb
Imports System
Imports System.Net
Imports System.Net.Cookie
Imports System.Net.CookieCollection
Imports System.Net.CookieContainer
Public Class Web4
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents push As System.Web.UI.WebControls.Button
Protected WithEvents a11 As System.Web.UI.WebControls.TextBox
Protected WithEvents at1 As System.Web.UI.WebControls.TextBox
Protected WithEvents at2 As System.Web.UI.WebControls.TextBox
Protected WithEvents at3 As System.Web.UI.WebControls.TextBox
Protected WithEvents at4 As System.Web.UI.WebControls.TextBox
Protected WithEvents thfff As System.Web.UI.HtmlControls.HtmlTable
Protected WithEvents tt1 As System.Web.UI.HtmlControls.HtmlTable
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub push_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles push.Click
a11.Text = Request.Cookies("us").Value
'Dim SessionCookie As New Cookie
'at1.Text = Request.Cookies("v").Value
at1.Text = Session("t")
at2.Text = Session("t1")
' at2.Text = Session("t")
' at3.Text = Session("t1")
' at4.Text = Request.Cookies("v1").Value
' End If
at1.Text = Session("t")
at2.Text = Session("t1")
at3.Text = Session("t2")
End Sub
End Class
Regards,
Shrinidhi.
|
|
|
|