Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Greatest Comon Factor


could anyone help me out with a code to a little prog which finds GCF of 2 numbers (from text boxes) using do while, loop. thx




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Personal Comon Dialog
Hi,

Long time since I programmed in vb6. Now i need to build a Common Dialog to get the path of a file. It can be anytype of file, but if it's a picture. I need to be able to see the picture in a picturebox. The problem isn't to get the file but how to return the path to the form that have called my "Common dialog".

How can I do that?

Thx

Customizing The Comon Control
Is it possible to customize the Open/Save dialog, similar to the way MS does in apps like Access, using only VB? Does it require the creation of an ActiveX control?

I looked through the articles on the home page but didn't find anything about this.

Comon Dialog Cancel Click
im using common dialogs to save my files and every now and then when i click on cancel it saves the file anyway but with no extention.
is there a way to make sure that it only does so on a save click, that on a cancel click it exits the dialog?

Signature -----------------------------------------------------------------------------------------------------Code:Private Sub Form_Load() 'Print to from, code my problems!
     Form1.Print "CanT SleeP!..... MusT PrograM!!!" & vbCrLf & "I need coffee, WhErE iS mY CoFfEe?!"
End Sub 'All things come to and end
------------------------------------------------------------------------------------------------------------------

Printing Without Comon Dialogue Control Or Any Object
I would like to know if someone has the code to print something from a text box to a printer without using any objects. I know we can use yhe common Dialogue but I don't want my programme to have 35 Dlls for what it does. This program only uses msvbvm60.dll and that is the only one I want to use. I want the user to be able to choos his printer.

Thanks, David

Loading And Saving Html With Comon Dialog And Text Box ??
Hey, I was wondering how you load the contents of a htm file from a common dialog into a text box, and also how to save the contents of the text box as an htm file with common dialog as well... can anybody help ?

Factor Button
hi how do you work out a factor in VB6? whats the code for that?

Zooming Factor
Got problem here, please help!!!

Do any 1 know how to use an image as a test to testing for zooming. I have problem making zoom 1x as the same with the actual image...

Rounding Factor
Hi,

I have an increase function that has several rounding options that could take place (i.e. Round to nearest penny, nearest nickel, low nickel, high nickel, etc.) for Penny, Nickel, Dime, Dollar.

Currently, I am writing a function that basically takes the increased amount and studies the last characters of the increased amount and through a select method, I determine how to output the new rounded value.

Does anyone know of a site or code they can share that does this already? Any help would be greatly appreciated. Thanks.

Please Help...calculate Prime Factor
Hi, guys...
I am a VB beginner. I have an assignment due tomorrow. But I have no idea how to program this one.
I have to put any number into the input box and find out whether it is prime factor or not. If it is not a prime factor then the picture box displays something like this: 10000 = 2*2*2*2*5*5*5*5. Also I have to use one function and one procedure.
Guys, please help me.

Need Help On Prime Factor Of Number C++
hello im new in learning c++ and i have a headache wrting a program of prime factor of a number..i have an example 12=1*2*2*3 but i dont know how to begin with this program?can anyone here help me please thank you

Making A Factor Program...
I've been trying to make a factor program, based on what I have made using basic on a zx spectrum +2. When I press the button to make it run the only output is:


Quote:




,1






What it's meant to do is it takes a number which is inputted and gets all the factors of that number.

I was wondering if someone could help me with it, here's my code


Code:
Private Sub Factorize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Factorize.Click
Dim Inputted As Integer
Dim Divide As Integer
Dim Check
Dim Check2 As Integer
Dim strText As String
'strTrext is the variable for storing the data
Inputted% = FactorInput.Text
'FactorInput is a text box
Divide% = Inputted%
strText$ = ""
'These loops are my own integer check, to check whether
when the numbers can be divided into the number and an
integer comes out
Do
Check = Inputted% / Divide%
Check2% = 1
Do
If Check2% = Check Then
strText$ = strText$ & "," & Check
Else
Check2% = Check2% + 1
End If
Loop Until Check2% = Check Or Check2% = Inputted%
Divide% = Divide% - 1
Loop Until Check = Inputted%
FactorView.Text = strText$
'FactorView is a rich text format which is set to read only
End Sub


Can anyone see what's wrong? all the coding looks fine to me

Long Data Type && Factor
Hi,
I world like help on 2 things in VB6 Please.

First. I understand the Long data type has a number range between approx -2 billion and +2 billion. Is there any other data type I can use to get a bigger number. For example, I would like to work out combinations with in varibles. To do this I need to Factor, (I think that is the correct name, and this is related to my second question) 49 * 48 * 47 * 46 * 45 * 44, the result from this calculation is bigger than 2 Billion. I think the Long data type is 16 bit, what I am looking for, I think, is a 32 bit data type. If there isn't a 32 bit data type, baybe there is a command or function that can multiply fractions, eg. 49 over 6 * 48 over 5 etc. This calulation here is obviusly the fornule to work out how many combinations there are to win the National Lottery Jackpot.

Second, as mentioned above, Factor. I am sure there is a VB6 Function that will Factor numbers, example, Function(6) would give a result of 720 that is 6 * 5 * 4 * 3 * 2 * 1. Does anybody know this function.

Thank you in advance,
DjJazzy.

How Do You Return The Factor Of A Number In The TextBox
This might sound simple for some one, but I'm wrecking brain on it. Ho do you return a factor of number. For example, a user will enter the number into a Text Box (txtFactorial) and the application will display the factorial of that number in a Label (lblFactorial)

Scaling Factor And Print Size
Hi Buddies,

I want to know what is scalingfactor of a printer.

I fetched ScalingFactorX of my Printer which is 150 . While LogPixelsX is 600( Which u call dpi).These Factors I fetched using
GetDeviceCaps( ) API .

Is there a way to know in how many inches a frontpage document will print on printer .


Thanx & Regards
Yujvendra

Need Some Advice On My Rec.delete Process, I Am Missing A Key Factor It Seems...
I am trying to delete a selected record that the user has selected via the combobox.

My code is the following:


Code:
Private Sub cmdDelete_Click()
Set cn = New ADODB.Connection
cn.ConnectionString = GetConnString
cn.Open

Dim sSQL As String
Set rec = New ADODB.Recordset
sSQL = "SELECT * FROM tblEmployee "
sSQL = sSQL & "WHERE EmLast = '" & cmbName.Text & "' "
MsgBox (sSQL)
rec.Delete
If Not rec.EOF = True Then
rec.MoveNext
MsgBox ("The employee record has been deleted.")
Else
rec.MoveFirst
MsgBox ("The employee record has been deleted.")
End If

rec.Close
Set rec = Nothing
cn.Close
Set cn = Nothing
End Sub


My issue is that I recieve the error, "Runtime error 374", Operation is not allowed when the object is closed."

The highlight is on "rec.Delete".

Any ideas on what I am missing?


Your time is deeply appreciated,
Azeccia

Least To Greatest?
How would you sort least to greatest?

Selecting The Greatest
Hey there,

Lets just say i have a database.. as such

AmountTime OpenedWindow
20seconds ICQ
80seconds IE
45seconds MSN
63Seconds VB
90seconds Kaza
86seconds Outlook


How do i write a function so that i can select the top 4 softwares which would be the one with the most amount and the rest just add them up and catogrize them under others which means my new database would look like

AmountTime OpenedWindow
90Seconds KAZA
86Seconds Outlook
80Seconds IE
63Seconds VB
65Seconds Others


Thanks once again!!

Value In Box Two Is The Greatest?:RESOLVED
Hell VB forums, first post here.

Im getting my Bachelors in ISS and one of my classes is intro to VB. This is our third week and Im a little stumped on this program. Basically we need to find the greatest number amongst three given ones. No text boxes can be left blank.

No matter where I place the highest number, I keep getting the MsgBox "The value in box two is the greatest number". Am I not using the > properly?


Code:
Private Sub cmdFind_Click()
'Local Variable Declarations for the three text boxes.
Dim intOne As Integer
Dim intTwo As Integer
Dim intThree As Integer

'Force the user to enter a number in each text box
If txtOne.Text = "" Or txtTwo.Text = "" Or txtThree.Text = "" Then

'Display a message box alerting the user of the empty fields
MsgBox "Please enter a number in each field."

Else

'Associate the variables with the text boxes
intOne = txtOne
intTwo = txtTwo
intThree = txtThree

'Find the greatest number of the three given
If intOne > intTwo And intThree Then
MsgBox "The value in box one is the greatest"
ElseIf intTwo > intOne And intThree Then
MsgBox "The value in box two is the greatest"
ElseIf intThree > intOne And intTwo Then
MsgBox "The value in box three is the greatest"
End If
End If
End Sub

Selecting The Greatest
Hey there,

Lets just say i have a database.. as such

AmountTime OpenedWindow
20seconds ICQ
80seconds IE
45seconds MSN
63Seconds VB
90seconds Kaza
86seconds Outlook


How do i write a function so that i can select the top 4 softwares which would be the one with the most amount and the rest just add them up and catogrize them under others which means my new database would look like

AmountTime OpenedWindow
90Seconds KAZA
86Seconds Outlook
80Seconds IE
63Seconds VB
65Seconds Others


Thanks once again!!

Least To Greatest Sort
This way I originally learned how to sort items was by using a nested loop. That was really slow.
I optimized the code and got rid of the nested loop and speeded it up!(Easily edited to make it do least greatest)
Check this out!
I don't think its anything special and propably there are ven faster ways or somebody allready tryed this, but oh well:

For x = 1 + y To 100
y=1

If var(x) > var(y) Then
n1 = var(x)
n2 = var(y)
var(y) = n1
var(x) = n2
End If

Next x

Thoughts, comments? Just though it was interesting.

Print Greatest Number
I have 3 text boxes into which I enter 3 different numbers. upon clicking a command button the greatest of the 3 numbers is to be displayed in a label. can anyone help

What Must Be The Greatest Or The Best Program Made By Vb6?
what must be the most powerful,,yet not so complicated,,best,,outstanding,,#1 program made by vb6??

THANKS!!

Simple Value Question, Greatest Value
I'm making a very simple program, to put it simply I'm hoping to sort values according to input by the user. For example there are 5 values put in by the user, and on command I want those 5 values to be sorted from greatest to least in a list of labels. I'm having a very hard time figuring out the most efficient way to accomplish this...thanks a lot in advance.

Greatest String **RESOLVED**
I am currently in the middle of writing a Diff routine to find which of two string values is the greater.

The two values come from a sorted list held in two files respectfully.

When I pass a pair of single values to my routine this is easy to indentify which one is greater when they are numbers, in this case Primary Key.

But I want the routine to be dynamic, so I want to pass a string.


I have looked at CRC32, but the following test routine didn't return a sequence of ascending numbers.

I don't think CRC is the solution.

I tested this as follows:

Code:
Private Sub ICompare_TestCRC()
Dim MaxValue As Long, NewValue As Long, myIndex As Long
MaxValue = 0
For myIndex = 1 To 1000
NewValue = CRC.GetCRCFromString(CStr(myIndex))
If NewValue > MaxValue Then
MaxValue = NewValue
Else
Stop
End If
Next myIndex
End Sub

Anyone got any ideas how I can do this?

ActiveX EXE: The Greatest Sample.
Here you can find the best demonstration of making a Client-Server database application through LAN or Internet.

Its easy to understand, I got the point in a half an hour only by knowing basic things about ActiveX technology (DLLs & UserDocuments).

http://www.freevbcode.com/ShowCode.Asp?ID=3438

Download the appopriate link (cs.zip) from there. It needs VB6, maybe by removing some keywords from the .vbp files will work on VB5 too.

Greatest Common Divisor For Singles
I'm using the Euclid's algorithm for calculating the GCD, but my problem is that I can calculate only GCD of 2 integers and if I have for example 3400 and 12.5 the GCD is 12.5, but my program says it's 4, which is wrong:


Code:
Public Function gcd(a As Long, b As Long)

If (b Mod a) Then
gcd = gcd(b Mod a, a)
Else
gcd = a
End If

End Function
I even tried to convert b mod a to single CSng(b mod a) but still doesn't work... Is there any algorithm that will calculate the GCD for integers and singles or just for singles? I'm in great need. Thanks.

Query To Find Greatest Date
Using this query:

Code:
SELECT Schedule.JobID, Schedule.ResourceID, Schedule.Date1, TimelineItems.FamilyTypeID, OrderTimeline.ID
FROM (Schedule INNER JOIN TimelineItems ON Schedule.ResourceID = TimelineItems.InternalID) INNER JOIN OrderTimeline ON TimelineItems.TypeID = OrderTimeline.ID
WHERE (((Schedule.JobID)='TP03033') AND ((OrderTimeline.ID)='4'));
I obtain the records shown below (12 records). Each record is listed twice. If I remove the INNER JOIN of the OrderTimeline table, I get the correct number of records (6). Can someone explain why the JOIN duplicates these records? Also, what can I add to the SQL statement that will return the earliest date record? In this case, I want the record with the date of "20050518".


Code:
JobID ResourceIDDate1 FamilyTypeID ID
TP03033 425 20050518425 4
TP03033 425 20050519425 4
TP03033 425 20050520425 4
TP03033 425 20050523425 4
TP03033 425 20050524425 4
TP03033 425 20050525425 4
TP03033 425 20050518425 4
TP03033 425 20050519425 4
TP03033 425 20050520425 4
TP03033 425 20050523425 4
TP03033 425 20050524425 4
TP03033 425 20050525425 4
tia,
flynn

Find Which Variable Holds The Greatest Value
I have 6 variables (iProp1, iProp2, iProp3, iProp4, iProp5, iProp6) all integers holding a value between 0 and 100. How can I find the highest value, and do something else based on which was the highest, ie

If iProp is the highest then...

elseif iProp2 is the highest....

Thanks
Tom

Greatest Thing To Hit VB - Free 3d Engine
All I cany say is these guys are going to bring VB to a new level... in competition with C++ for games development...

True Vision 3D Engine

I found them after looking on www.gamedev.net, as they reported them as the new, easy, way to develop games...

Anyway, as a VB programmer, this is something I thought I'd share with all of you, since many of you, may be game or simulation programmers at heart.

Error In Looping Recordset To Find Record With Greatest Number
Hi All,

I have some code that opens all recordsets with a certain value and then loops to show the one with the greatest value. This code works but I get an error "Either BOF or EOF is true or the current record has been deleted" every time.

Code:
Public Sub VehicleScan()

Dim str As String
Dim rs As ADODB.Recordset
Dim Barcode, DateIn, TimeIn, TimeOut, Kms

On Error GoTo errortrap

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Driver.mdb;Mode=ReadWrite;Persist Security Info=False"
cn.Open

Barcode = Me.TxtBarcode.Text
   
Set rs = New ADODB.Recordset
rs.Open "select * from Vehicles WHERE [BarCode] = '" & TxtBarcode.Text & "'", cn
    
    LblVehicle.Caption = rs!Vehicle
    LblSchedule.Caption = rs!Schedule
    LblCycles.Caption = rs!Cycles
    LblKms.Caption = rs!Kms
    LblRunTime.Caption = rs!RunTime
    LblPriority.Caption = rs!Priority
    LblJobNo.Caption = rs!JobNo
    DateIn = rs!DateIn
    TimeIn = rs!TimeIn
    TimeOut = rs!TimeOut
    
    Do Until rs.EOF
        rs.MoveNext
        Kms = rs!Kms
            If Kms > Me.LblKms.Caption Then
                LblVehicle.Caption = rs!Vehicle
                LblSchedule.Caption = rs!Schedule
                LblCycles.Caption = rs!Cycles
                LblKms.Caption = rs!Kms
                LblRunTime.Caption = rs!RunTime
                LblPriority.Caption = rs!Priority
                LblJobNo.Caption = rs!JobNo
                DateIn = rs!DateIn
                TimeIn = rs!TimeIn
                TimeOut = rs!TimeOut
            End If
    Loop
    
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing

If TimeOut = "" Then
    Me.TxtComments.Text = "Please enter cycles and press enter"
    Else
End If

Call AddData

errortrap:
If Err.Number <> 0 Then
    If Err.Number = 3021 Then
        Else
        MsgBox Err.Number & " " & Err.Description & " " & Err.Source
    End If
    Err.Clear
End If

End Sub



dose anyone know of a better way to do this?

Thanks,

Ben

Copyright 2005-08 www.BigResource.com, All rights reserved