Sunday 24 March 2013

Solution to VB6 Mouse Functions Don't Work


Error:


The error was 
"The module "X:\path\VB6IDEMouseWheelAddin.dll" was loaded but the call to DllRegisterServer failed with error code 0x80004005
For more information about this problem, search online using the error code as a search term."





Fix for the problem:

First Download and unzip it to any locatoin, keep the location in mind.

This is how I had to fix it, I had to create a batch file and then run it as administrator. How do you do it?

Go to Run, i.e.) Windows Key + R and type in "Notepad" without quotes and it should open up.


Or  key in "Notepad" at Start Menu Search, you should get it





Now in the notepad window, enter the following,

X:\Windows\System32\RegSvr32.exe "Y:\Dir\VB6IDEMouseWheelAddin.dll"

Where is your Windows Drive, in my case 'C' drive and is the drive where you have your file, i.e., where you unzipped it, suppose it is in G:\MouseWheel\VB6IDEMouseWheelAddin.dll then put that in there between the quotes.

Now its simple, save the file as .BAT file and not .TXT

Click Save As




In Dialog select "All Files" from dropdown list and Type filename.BAT








Save it.


Now right click on your saved BAT file and Run as Administrator, that's it. It's now loaded.





Now the remaining part in VB6, open up VB6.

Go to Add-Ins -> Add In Manager




Select MouseWheelFix and check the boxes below "Loaded/Unloaded" and "Load on Startup".



That's it. You are good to go, mouse will now work fine. :)

Thursday 21 March 2013

BMI Calculator | Source Code


Here is the coding for the BMI Calculator, a simple code with switch case statements to get the BMI value.


'Declarations 
Dim wt, ht, bmi, htsq
'On Click of Button
Private Sub Command1_Click()

'The Calculation Part of BMI --- 
'<--- Calculation Starts ----

wt = Val(Text1.Text)
ht = Val(Text2.Text)
'Height ---> Inches to Meters Conversion
ht = ht * 0.0254
htsq = ht * ht

bmi = (wt / htsq)
'Rounding the Float bmi to 2 decimal places
bmi = Format(bmi, "#00.00")

'Display the bmi float value
Label5.Caption = bmi

'To Display the Appropriate Text with respect to the value of BMI
Select Case bmi
Case Is < 18
Label3.Caption = "You are UnderWeight for your Height"
Case Is < 18.5
Label3.Caption = "You are Thin for your Height"
Case 18.6 To 24.9
Label3.Caption = "You are Healthy"
Case25 To 29.9
Label3.Caption = "You are OverWeight for your Height"
Case Is > 30
Label3.Caption = "You are Obese"
End Select
' --- Calculation Ends --->
End Sub

Here the Text1, Text2 are the fields for getting the Weight in Kgs and Height in Inches.

Then on the Click of the Button (Command1) we display the output using Label5 which shows bmi value as float and Label3 which shows the statement as per bmi value.

The final product is as follows,

Wednesday 20 March 2013

Net Run Rate Calculator | Source Code

So here is our first application, a simple VB 6 application to calculate the Net Run Rate for Cricket Matches. We hope that this would be useful for anyone who manages small scale Cricket Tournaments or such. :)

'Declaring the required variables

Dim t1, t2, ov, rr1, rr2, nrr1, nrr2
______________________________________________________________________________
'Program to Calculate the Net Run Rate and Display on Click of Button

Private Sub Command1_Click()

t1 = Val(Text1.Text)
t2 = Val(Text2.Text)
ov = Val(Text3.Text)

'--- To Avoid Error when button clicked without Entering values to calculate ---
'<---Starts here---

Select Case ov
Case ov = ""
ov = 1
End Select

Select Case t1
Case t1 = ""
t1 = 0
End Select

Select Case t2
Case t2 = ""
t2 = 0
End Select
'--- Ends here--->
'--- Run Rate Calculation ---
rr1 = t1 / ov
rr2 = t2 / ov

nrr1 = rr1 - rr2
nrr2 = rr2 - rr1

Text4.Text = nrr1
Text5.Text = nrr2

End Sub

______________________________________________________________________________


This is the only Coding part. It is very simple, once you get the hang of it.

Here,

Command1 is the Button on which the Calculation Takes place

Text1 is the Text Field used to get the Team 1's score, Text2 is the Text Field for Team 2's score, Text3 is where you input the number of overs.

Text4 and Text5 are used to display the Net Run Rate Calcuated.

This is what the end program looks like


Here we go....

Finally we have got a blog up and running. We hope that we would be able to post our codes in here, which might be useful for all those budding programmers out there.

Also, it'd give us confidence to move ahead with larger strides. :)