Tracker
 ASP PHP JavaScripts MySQL MS Access MSSQL VISUAL BASIC Subjects/Titles Post Text/Content
HOME    TRACKER    Visual Basic

# 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.

Convert Long Data Type To Integer Data Type
I am trying to convert an array from a long data type to an integer data type. When I use the Cint() function I am getting an overflow error. Is there a way around this? Basically what I am trying to do is to convert two successive 16 bit representations (stored as a long) number into a floating point using the MoveMemory API. The .ReadResults is an OCX defined function that reads MyLongData(j) from Memory and stores into a long data type.

Code:
Dim MyIntData(2) As Integer
Dim MyLongData(2) As Long

Dim fValue As Single
Dim j As Integer

For j = 0 To 1

MyStatus = MbMasterV71.ReadResults(hConnect, Slave, Cmd, RegStart + j, MyLongData(j))

Next j

MyIntData(0) = CInt(MyLongData(0))

CopyMemory fValue, MyIntData(0), 4

Long Number Data Type
Hey all (again, sorry for all the questions ^^;; )

I'm just wondering if there's a data type or if one can be made for storing very long numbers, but being able to perform mathmatical calculations on them? (i.e. not a string).

I want to use the Rnd function to generate a 20-digit number, e.g. 40229603967719402863. I can't store it int/long/etc as it's too long, I can store it in Double but then it makes it a floating point number.

Soo.. Any way to generate a number of this size and have it display the full value? I'm trying to generate a unique ID, you see

Retrieving Long Data Type
Folks,

I am trying to retrieve data from a table/column where the datatype is LONG. Database is Oracle. For some reason, I am unable to retrieve the entire content of the column. The amount of data to be retrieved is very small ... 500-800 bytes but for some reason, the records get truncated to 256 bytes. I have found that if the length of data in the column is 256 bytes or less then the whole text is retrieved other wise it gets truncated to 256 bytes.

I am using ADO 2.7 and am using the getchunk method of ADODB.recordset. Can you please tell me what could be the issue here?

Thanks

How To Pass A Long Data Type To A ADO.parameter?
I want to know how to pass a long data type to an ADO.parameter object. For instance if your parameter is a string you can set the Type property of the parameter to adVarChar or if its integer, Type=adInteger etc... Which constant would be used if your parameter is of data type long?

Thanks,

Search/Filter On Long Data Type In Oracle 7.3
Hello,
Can anyone tell me if its possible to search or filter on a long data type using VB and ADO. My database is Oracle7.3 and due to certain limitations its not possible for me to upgrade my database to a higher version of Oracle.

Long Is Faster Yet It&#039;s 4 Bytes And Integer Is 2 Bytes, And Other Data Type Questions
I read in the MSDN library that a long data type should be used whenever possible because it is the processors native data type and therfore more efficient. Why is this if it's 4 bytes and the integer is 2 bytes?

Also, it sayed you should only use decimal when absolutely neccessary when dealing with math so that the math co-proccessor is utilized less. What data type can I use that when divided by an indivisable value won't return a decimal value? I usually use the round() functiln.

Any help would be great thanks.

Long Type To UDT
Hello.

How do I cast a long to a UDT?
the long type value is a return from an API function.

UDT:

Code:
Public Type NewEventData
Result As Long
UserId As Long
UserNum As Long
End Type

I tried using CopyMemory but my app crashes when I use it.

SQL Server - The Conversion Of A Char Data Type To A Datetime Data Type Resulted.....
Hi All

I have developed an application with vb6.0 and sql server 2000 database and working well on my desktop.

While client saving records in db, sometimes they are getting following error.

"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."

I'm using ADOs and code like this...

rstCustomer("joindate") = mskJoinDate
rstCustomer("jointime") = mskJoinTime
rstCustomer.Update

' Here mskJoinDate is maskedit control, contains date in dd/mm/yyyy format only.

' Here mskJoinTime is maskedit control, contains Time in hh:mm format only.

' Both are datetime fields in database.

' These two fields won't contain any other data because I have done perfect validation before assign values to recordset.

Save Long Type
Hi Folkz, i have a question (really? ):

i have to say a long type.
Es.

Code:
Public Type TypeExample

Pasta as string
Pizza as boolean
Spaghetti as variant
.
.
.

End Type

Public Food as TypeExample
how can i save with a functions this structure?

a thing like WriteType #1, Food

does exist anything like this?

Sorry for my english

Overflow Even With Long Type
hi,
i have a long type variable for division operation...but i always get
runtime error '6': overflow.....code is like below

Dim formula_result As Long

formula_result=40000/5561

then it crashes...

what can i do about that?

Converting To Long Type
anybody know how to convert a c-type 64 bit integer to long type in vb?
i tried CLng() but it results in an error because it is out of range..

such as -11644473599 converted to 1240428289

any suggestions?

'The Conversion Of A Char Data Type To A Datetime Data Type Resulted In An Out-of-ran
Hi,

I am writing a SQl query in visual basic by startdate and end date. It works fine in SQL server and Query Analyser but when query comes into visual basic it error and the message is 'The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.'

The code:

declare @cMonth int, @year varchar(10), @first_sDate datetime, @first_eDate datetime, @Second_sDate datetime, @Second_eDate datetime
set @cMonth = datepart(month, getdate())
set @year = datepart(year, getdate())
set @first_sDate = @year + '-01-01' + ' 00:00:01'
set @first_eDate = @year + '-06-30' + ' 11:59:59'
set @Second_sDate = @year + '-07-01' + ' 00:00:01'
set @Second_eDate = @year + '-12-31' + ' 11:59:59'

if @cMonth <= 6
begin
select *
from pub
where created_date BETWEEN @first_sDate and @first_eDate
end
else
begin
select *
from pub
where created_date BETWEEN @second_sDate and @second_eDate
end

In here two sets of data need to represent first six month and second six month.

how do change varchar to datetime? I tried convert but didnot work. Any body can help with the code? The error caused only in visual basic.

Many Thanks

Bravo

Convert Type Long To Date
Hello everyone,

Please tell me how can I convert a type long ("20031217180537011") into datetime format!

Best regards

Tpe Mismatch Using Long Variable Type
I am not sure what the problem is here - maybe someone can help me out fairly easily.

I Dimmed variable as long, Value at run-time is 123456789 (test figure), and it is coming up as type mismatch error

In the global decs I have:

Code:
Dim gstrUnKey as Long

In the private sub, I have:

Code:
If IsNumeric(gstrUnKey) & gstrUnKey > 0 Then
'this creates the error when variable = 12345678 or 123456789

Type Mismatch...Data Type Vs. Host Data Type?
I keep receiving the "Type mismatch" error, and I think it stems from several fields containing dates which I am trying to update into a MS Access database. What I am trying to determine is what would be the proper settings for the "Data Type" and "Host Data Type", under the Parameters tab in my Command properties? The format I am hoping to achieve is mm/dd/yyyy. (This is already correctly set in my Regional Settings.) I hope this makes sense...I have been searching the forums and haven't found any descriptions yet of the various options for these two settings.

What's The Fastest Variable Type? Long, Integer, Etc...
Long, Integer, Single, etc.. Could someone who knows a little about the compiled code respond with the order from fastest to slowests, all of the VB variable types? Thanks for your help.

Type Or Class For My Project? ...and Intro (kinda Long, Sorry)
Hi,

I am an old guy who just won't stop trying to learn to program in spite of the strong recommendation of friends and family. I started with Extended Color Basic in 1980, went through DOS batchfiles, C console apps, HTML and JavaScript and most recently failed to really learn C++. I do fine with straighforward scripting in things like PovRay and GameMaker, but until this last year haven't really had time to dig into the more complex issues of a real language. I mostly do Computer Animation, having made a little money at it over the years. But now I really want to learn to program right.

I'm using VB6, the MSDN site (since my version of MSDN won't seem to install right), "Visual Basic 6 Complete" by Steve Brown, and sites like this.

I seem to be doing better this time around, some of the concepts seem to be sinking in. My goal is to create some of the little handy programs that I keep searching for on the internet and which keep turning into overly complex suites while going from freeware to Commercialware and having spyware added.... deep breath ... rant over...

Anyway, right now I am trying to learn more about the care and feeding of user defined types, but I think my project might actually work better with a class or two.

The program is a math testing program which measures the time and percent correct of a range of problems. The user can set the operations used, the range of values to be added, subtracted, multiplied or divided, a few other things like how problems are displayed or how the answers are entered.

It -should- also keep track of an array of students, allowing them to call up their settings, keeping a graph of their improvement, and adding to the challenge factor as they learn.

I believe I can easily do it all without types or classes, in fact, I am just duplicating a program I wrote in a scripting language (GML). But the WholeIdea™ is to learn about VB, This week, specifically types, but in general, good programming techniques.

So I was thinking, from my fairly ignorant proceedural background, and from reading the "Class vs Module" debates on this board, that maybe Classes would be better for my purpose.

I have at least two prospects applying for the position of Class. First I have "Equations", a "Thing" that must hear "range1", 'range2', 'operation' and "format" and must do "Randomize", "don't match operand pair", "don't match neighbor" and "compare answers"... etc. I will have a varying number of these, depending on user settings and student ability.

Also I have 'Students' who have Histories, Scores, Settings(Format,PrintOptions,etc.), Passwords and TeacherSettings etc., and who must do, obviously, "Their math homework".

Formerly I have saved these in an INI style file and read them into various global.arrays. But in the interest of learning what I really -should- do, I want to rewrite them with Types... or maybe Classes if it is the better solution.

Opinions? Thanks in advance. ...and thanks in retrospect for the info I have recieved from your past posts. Great reading over these last weeks.

Bill, the KodeWorrier, apologizing for the lengthy essay.

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

Zooming Factor

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.

I am getting this Error while generating the report

my query is

SELECT R.* , S.* , SLC.DLEFT, SLC.CLASS_ID, r.reg_ph_res_code//' '//r.reg_ph_res as reg_ph ,
r.reg_ph_res_code//' '//r.reg_ph_res1 as reg_ph1 ,
r.reg_ph_off_code//' '//r.reg_ph_off as reg_ph_off ,
r.reg_ph_off_code//' '//r.reg_ph_off1 as reg_ph_off1 ,
s.gph_res_code//' '//s.gph_res as g_ph,
s.gph_off_code//' '//s.gph_off as g_ph_off,
r.fname//' '//r.mname//' '//r.lname as sname
FROM REGISTRATION R, STUDENT S, SLC
WHERE R.REGISTRATION_ID = S.REGISTRATION_ID
AND S.STUDENT_ID = SLC.STUDENT_ID (+)
and s.student_id = 102400
(this query is correct it work in pl/Sql interface (oracle) )

in this query many feilds are empty ..........
if error is due too this then How can I prevent.

I am using DATA Environment, and its s Single query (not hierarichal Records)

Edited by - haahoou on 2/6/2004 12:36:29 AM

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.

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

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

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

Converting ADO Data Type To DAO Field Data Type
friends
i am getting the datatype of the field from the database, but i am unable to convert to ADO data type to DAO field data type is it is possible is there any functions for it in VB

VBA Data Type For SQL Server 2000 Int Data Type
Can someone please refresh my memory?

If I have a SQL Server int data type, should I use a Long data type in VBA?

------------------------------------------------------------------------------------------------
Put your PC to good work at vbCity at world community grid and join Team vbCity.
2,669,763 3,325,308 points and ranked 1,195 1,149 as of March 8 May 23, 2008!
------------------------------------------------------------------------------------------------

Edited by - Geof on 7/2/2007 8:33:10 AM

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

How To Open Data Stored As Long Binary Data?
I searched this forum but can't find the answer, hope you can help me out.

I am using VB6 to retrieve records stored in SQL Server 2000. The information I want to retrieve stored as Long Binary Data. The binary they stored called Varbinary or Binary......
Is there a way that I can query out as text?
Pal.

How To Dynamically Change A Data Type Of A Variable From One User Defined Type To Another
I have a situation like this. I want to declare a variable of a user
defined type that changes dynamically.
Like i have a user defined type called type1 and another called type2.
And i use

DIM var1 as type1

At later point of time i want the same variable to be declared to
type2. Use of REDIM is for arrays only and not for user defined types.
Is there any solution? Your suggestions would be of great help to me

Bye
Tej

Type-declaration Character Does Not Match Declared Data Type
Type-declaration character does not match declared data type?
I don`t get it
This error message appears and Left\$ is marked in the code, I guess it has something to do with types, but what?

Code:
Open Sti & "DeaktiverteDager.txt" For Input As #1
While Not EOF(1)
Line Input #1, LinjeITekstFil
LinjeLengde = Len(LinjeITekstFil)
RestAvLinje = LinjeLengde - 2

If Left\$(LinjeITekstFil, 1) = Left\$(label10.caption) Then
For i = 0 To 4
If Mid\$(LinjeITekstFil, 3, RestAvLinje) = Label3(i).Caption Then
Label3(i).Visible = False
Label5(i).Visible = False
Text1(i).Visible = False
Text2(i).Visible = False
Command1(i).Visible = False
Command2(i).Visible = False
List1(i).Visible = False
List2(i).Visible = False
End If
Next
Wend
Close #1

Type-declaration Character Does Not Match Declared Data Type
I am getting compiler error "type-declaration character does not match declared data type" . It's highlighting Left\$
LVGetItemText = Left\$(objItem.Text, nRet)

Derclarations are as below.
VB Code:
Private Type LV_ITEM   Mask As Long   Index As Long   SubItem As Long   State As Long   StateMask As Long   Text As String   TextMax As Long   Icon As Long   Param As Long   Indent As LongEnd Type Public Function LVGetItemText(lParam As Long, hwnd As Long) As String   Dim objItem As LV_ITEM   Dim nRet As Long   'some code   If nRet Then      LVGetItemText = Left\$(objItem.Text, nRet)   End Ifexit function

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()
cn.ConnectionString = GetConnString
cn.Open

Dim sSQL As String
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?

Azeccia

SQL Error: Char Data Type Conversion To Datetime Data Type Error
I created an application which, in one instance, queries an
SQL Server 7 table based on a date entered.
I have installed it on 4 machines (one NT, two 98 & one 95).
It works fine on all but one of the 98 machines.

On this !one! machine I receive the following error:
Error 2147217913 was generated by Microsoft OLE DB provider
for SQL Server The conversion of a char data type to a
datetime data type resulted in an out-of-range datetime
value.

I get the date from a datepicker with the format
"dd/MMM/yyy HH:mm:ss"

Help!

How To Free Memory Occupied By "LONG Or INT TYPE" Variables In VB?
Hii all,

How to free memory when you have too many "LONG or INTEGER" type variables?

I know you can use "ERASE" command to free memory occupied by arrays. But it does not work for "LONG or INTEGER" type variables.

HDave

Vb Data Type Data Type Question
I have a parameter declared as a long in one of my functions...someone tried to pass an integer to it and got a type mismatch error? Can anyone explain the reason that would occur?

Help Get Certain Data From A Long String
I have a long string like this:
CMP_0708114242.txt 9 3 5 9 3 0 6 9 - 9 5 2 2 9 8 6 - 3 3 7 4 _ C l a s s e s C L S I D { 0 A F A C E D 1 - E 8 2 8 - 1 1 D 1 - 9 1 8 7 - B 5 3 2 F 1 E 9 5 7 5 D } s h e l l e x I c o n H a n d l e r  ,´¨vd¶¨v CMP_100708113838.txt crosoft Network  T r a n s I m p l e m e n t a t i o n CMP_140708134343.txt 9 3 5 9 3 0 6 9 - 9 5 2 2 9 8 6 - 3 3 7 4 _ C l a s s e s I n t e r f a c e { 0 0 0 0 0 1 0 e - 0 0 0 0 - 0 0 0 0 - C 0 0 0 - 0 0 0 0 0 0 0 0 0 0 4 6 } P r o x y S t u b C l s i d 3 2 8¼n T r a n s I m p l e m e n t a t i o n CMP_150708145757.txt
CMP_160708121919.txt Û# `Ü#  PÛ# xÜ#    " :  ˆ ˆ M i n i p o r t ( P P T P )

I need find those files with ".txt", How do I do it? Thanks.

Double Long Data
Because long integer values are limited to the range (-231, 231-1) I thought I could work on creating a "extralong" integer data type consisting of 8 bytes (2 longs, a high order and a low order) and define a set of basic operations +,-,*,,/, maybe in a class or a dll. The purpose is to be able to work out combinatorial calculations where results grow very large even for small input.

I wonder if any such thing exists and if it looks like a sound idea.

How To Clear Long's Data?
Dear VB City Friends,

Let said, i declare user_login as Long, when i add the user_login's ID to my database, can i know how to clear the ID of user_login. I am trying to put like this:

But it will pop up an error message, can i know how to fix this problem?

From,
Nicholas

Anything Bigger That "Long" Variable Type?
Is there a variable type larger than long that can be used?

ADODB Data Source Name Too Long?
G'day,

I am brand new to ADODB and I was wondering if there was an alternative way to do this piece of code, because I am getting a message saying the data source name is too long, but I don't want to change the path where the database is located.

cnnMailMerge.Open CurrentProject.Path & "mailmerge.mdb"

I know I know, it's probably the simplest little thing, but I'll never know if I don't ask. Thanx

Help:how To Open Long Binary Data
I have an OLE Object field in a table in a MS Access 97 database. I must/have to:
1) use ADODB.Stream to save files(ie. *.doc) to database and the data type is "long binary data".
2)open those files from the database (not from exporting the stream to a new file).
I can do #1 but don't know how to do #2 because there is no OLE header for long binary data. Does anyone know the solution? Thanks!

Binary Data String/long
is there a way to manipulate binary data that consists of alternating strings and longs without the use of a file? say for instance inside of a textbox?

Data Types And Long Numbers
I have the following calculation

VB Code:
BigNumber = 10000000000000SmallNumber = 943 MsgBox BigNumber SmallNumber

When using any of the Data Types I always get Error 6 "Overflow" returned, is there any way around this?

Matt

How Long Does Data Stay In The Buffer For MSCOMM?
I'm having the ****est time troubleshooting my code. It seems if I place a break in the MSCOMM1.OnComm that I will loose information from my buffer. I'm thinking that by the time I hit F8 or F5 that the buffer has been emptied.

Any tips on troubleshooting code that is working with MSCOMM when you run into this issue?

Longer Than Long? - Custom Data Types
I'm trying to make a custom data type to that I can convert a program that uses long integers to use integers with a length of N bytes where N may be 64 or larger. I haven't a clue where to start as I've never used custom data types in VB

Long Binary Data Instead Of Word Document?
hello, i have the following code:

objstr_sig.Open
rst.Update

i recently posted a problem with the code but determined the answer. i now have a new problem. the file does make its way to the specified field in access, but it is in long binary data form instead of word document form. any suggestions why and how to fix.