|
-
Nov 8th, 2008, 04:59 AM
#1
Thread Starter
Fanatic Member
Re: Skipping in for loop
 Originally Posted by dee-u
You could set a condition inside the loop, using INSTR function to determine the existence of '/' in the data....
I used the coding Below but not working.
Private Sub Command1_Click()
rs.Open "check1", db, 3, 2
If InStr(no1, "/") > 0 Then
a = Left([no1], InStr([no1], "/") - 1)
b = Right([no1], Len([no1]) - InStr([no1], "/"))
c = a / b
Call calc
Else
no1 = no1 / 1
Call calc
End If
rs.Close
End Sub
Private Sub Form_Load()
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Bharani\Desktop\New Folder (2)\check.mdb;Persist Security Info=False"
End Sub
Private Sub calc()
rs.Open "check2", 3, 2
rs.AddNew
rs.Fields(0) = no1
rs.Update
rs.Close
End Sub
My output needs to be 5.5, 2.67, 7, 9
which must be added to database
-
Nov 8th, 2008, 05:26 AM
#2
Re: Skipping in for loop
For parsing a fraction it may be easier to use a split...
Code:
Dim data() As String
Dim firstValue As Long
Dim secondValue As Long
data = Split("100/50", "/")
firstValue = data(0)
secondValue = data(1)
MsgBox firstValue / secondValue
There is no code the save the record yet, you have to include it also if you want to save...
-
Nov 8th, 2008, 07:46 AM
#3
Thread Starter
Fanatic Member
Re: Skipping in for loop
 Originally Posted by dee-u
For parsing a fraction it may be easier to use a split...
Code:
Dim data() As String
Dim firstValue As Long
Dim secondValue As Long
data = Split("100/50", "/")
firstValue = data(0)
secondValue = data(1)
MsgBox firstValue / secondValue
There is no code the save the record yet, you have to include it also if you want to save... 
I used your coding as this
but not working
Private Sub Command1_Click()
rs.Open "check1", db, 3, 2
Dim data() As String
Dim firstValue As Long
Dim secondValue As Long
data = Split("100/50", "/")
firstValue = data(0)
secondValue = data(1)
MsgBox firstValue / secondValue
End Sub
It only dividing the values which is 100/50 = 2, but i want my recorset values to be divided .
-
Nov 8th, 2008, 07:52 AM
#4
Re: Skipping in for loop
That was just for demo purposes, of course you have to modify it to suit your needs...
-
Nov 8th, 2008, 07:57 AM
#5
Thread Starter
Fanatic Member
Re: Skipping in for loop
 Originally Posted by dee-u
That was just for demo purposes, of course you have to modify it to suit your needs... 
Ya But Instead of that 11/2 i specified my recordset field name as no1, but it is showin error as type missmatch
-
Nov 8th, 2008, 08:13 AM
#6
Re: Skipping in for loop
You have to replace
Code:
data = Split("100/50", "/")
with your own data...
Last edited by dee-u; Nov 8th, 2008 at 08:17 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|