How to do conversion certain munber to code

more like digit by digit conversion

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1385 Views - Last Post: 19 June 2009 - 06:40 PM Rate Topic: -----

#1 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

How to do conversion certain munber to code

Post icon  Posted 28 May 2009 - 12:43 AM

Hi there, i am working out on some programming stuff.

A)i wanna to ask is it possible that by just using VB with the math related
function to create something like this.

EG: given 5436 will be 0431( the changes is when a ny digit greater than 5 will be deducted by 5)

if is possible can u give me some hint because i previously use the excel can make it done but now i try to work it on the vb i dun really master in those coding but willingly to learn.

any one can help??

thanks you

Is This A Good Question/Topic? 0
  • +

Replies To: How to do conversion certain munber to code

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 28 May 2009 - 01:48 AM

need your part of work first, then we will make you to move around that topic
Was This Post Helpful? 0
  • +
  • -

#3 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 28 May 2009 - 02:14 AM

you mean i need to put my code that i try to work at here??
ok i try to send my code up later as now i still trying my bet to work it out.
tq for the reply
Was This Post Helpful? 0
  • +
  • -

#4 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 28 May 2009 - 10:22 PM

ya this is my new work out
i think i have succeed to do conversion
but there is a matter where if my input start iwth 0xxx or 5xxx
i will only show 3 digit and not 4 digit
can help me on this???
i know may be the way i use is quite long but this is all in one command button.

hehe
pls help tq

Text2.Text = Val(Text1.Text) Mod 1000
Text4.Text = Val(Text1.Text) Mod 100
Text6.Text = Val(Text1.Text) Mod 10
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
Text5.Text = Val(Text1.Text) - Val(Text3.Text) - Val(Text4.Text)
Text7.Text = Val(Text4.Text) - Val(Text6.Text)
Text8.Text = Val(Text3.Text) / 1000
Text9.Text = Val(Text5.Text) / 100
Text10.Text = Val(Text7.Text) / 10
If (Text8.Text) > 5 Then Text11.Text = Val(Text8.Text) - 5 Else Text11.Text = Val(Text8.Text)
If (Text9.Text) > 5 Then Text12.Text = Val(Text9.Text) - 5 Else Text12.Text = Val(Text9.Text)
If (Text10.Text) > 5 Then Text13.Text = Val(Text10.Text) - 5 Else Text13.Text = Val(Text10.Text)
If (Text6.Text) > 5 Then Text14.Text = Val(Text6.Text) - 5 Else Text14.Text = Val(Text6.Text)
Text15.Text = Val(Text11.Text) * 1000 + Val(Text12.Text) * 100 + Val(Text13.Text) * 10 + Val(Text14.Text)
Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 29 May 2009 - 03:06 AM

yeahhh, that's the spirit
sure wait one day i am in a urge i will post a simple code for you and i will surely explain those things

let's try to make some small changes in your code remove the number of textboxes instead of use the variables in your code

see you later

This post has been edited by thava: 29 May 2009 - 03:06 AM

Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 29 May 2009 - 05:58 PM

let's check out this code
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i As Integer
If IsNumeric(Chr(KeyAscii)) Then
    i = Val(Chr(KeyAscii))
    If i >= 5 Then
        Text2.Text = Text2.Text + CStr(i - 5)
    Else
        Text2.Text = Text2.Text + CStr(i)
    End If
    Text2.Text = Format(Text2.Text, "######0")
End If
        
End Sub



try to understand it other wise i will explain you
Was This Post Helpful? 0
  • +
  • -

#7 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 29 May 2009 - 06:47 PM

ya i understand what u doing,
your code will produce any code that i wan with what number that i have put in.

but it will show both of the number and code that i wan

it will produce something like this
EG: 0598 suppose produce 0043

but the text box display89500043

and it cannot be done with this.
can it just display the code only??

ya by the way just wanna to confirm since this coding procedure will be use more than 60k++ times and source from almost 25 different field.
. so my question here is can i make a function for using this code then call it whenever i need it?
and can this code be save in the access once i key in the input.
as for ur infomation all my data is i fetch from one of my access table. so each time i have new data i will open this program then key in directly the data, after that confirm the coding conversion then do some analysis.

pls help and tq for the previous code.
haha save lot of lines :) :rolleyes: :D
Was This Post Helpful? 0
  • +
  • -

#8 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 29 May 2009 - 07:11 PM

why not here is a procedure
Private Sub getCode_on(TxtBox As TextBox, KeyAscii As Integer)
    Dim i As Integer
    If IsNumeric(Chr(KeyAscii)) Then
        i = Val(Chr(KeyAscii))
        If i >= 5 Then
            TxtBox.Text = TxtBox.Text + CStr(i - 5)
        Else
            TxtBox.Text = TxtBox.Text + CStr(i)
        End If
        TxtBox.Text = Format(TxtBox.Text, "######0")
    End If
End Sub


and call like this on any textbox's keydown
Private Sub Text1_KeyPress(KeyAscii As Integer)
    getCode_on Text2, KeyAscii 
    getCode_on Text13, KeyAscii
End Sub



Quote

but there is a matter where if my input start iwth 0xxx or 5xxx
i will only show 3 digit and not 4 digit


that's why i add the format function if you want this just remove that line only

This post has been edited by thava: 29 May 2009 - 07:14 PM

Was This Post Helpful? 1
  • +
  • -

#9 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 31 May 2009 - 06:59 PM

hi , i dun know what really happen that the first part of the code that in ur last post , when i try to run it
it tell me run time error424 then object required. i think i have put all the code that u give.
but that the problem
then line 8 is highlighted
TxtBox.Text = TxtBox.Text + CStr(i)

i dun see any prob with the line but the line keep higglighted.(yellow)

can further help?
Was This Post Helpful? 0
  • +
  • -

#10 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 31 May 2009 - 07:41 PM

One more thing only textboxes allowed in this funtion

getCode_on Text2, KeyAscii

where text2 is a textbox name

so you should pass the textbox name there ,
pass the textbox name in which textbox you want the result
Was This Post Helpful? 0
  • +
  • -

#11 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 01 June 2009 - 12:16 AM

from what u say u mean only on a new project that have new formcan be used for that code?

so my current project can have it rite?

i also not very sure on what i say, as i try what u advise on a new project it can run but once i apply it on my current project file it still indicated the same prob.
but i will try.

ya a kind of new question here.
can a rich text box or text box show from multiple input

EG:
text 1: 3124
text 2:5436
text 3:4564
what i wan is in text box 4 got/show

3124
5436
4564

i try to put these code in a command button
text4.text=text1.text
text4.text=text2.text
text4.text=text3.text

so that when i press that button it will show all the stuff in it but it only show the first data which is 3124
can give me some hint on that matter
Was This Post Helpful? 0
  • +
  • -

#12 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 01 June 2009 - 06:36 PM

richtextbox and textbox
both are show like what you want

in textbox
change the property multiline to true
and
change the property scrolbars to 3-both

yes it is possible
Private Sub Text1_Change()
addtext
End Sub
Public Sub addtext()
Text4.Text = Text1.Text + vbNewLine + Text2.Text + vbNewLine + Text3.Text
End Sub

Private Sub Text2_Change()
addtext
End Sub

Private Sub Text3_Change()
addtext
End Sub




and one more thing just change the code to module like this
Public Sub getCode_on(TxtBox As TextBox, KeyAscii As Integer)
	Dim i As Integer
	If IsNumeric(Chr(KeyAscii)) Then
		i = Val(Chr(KeyAscii))
		If i >= 5 Then
			TxtBox.Text = TxtBox.Text + CStr(i - 5)
		Else
			TxtBox.Text = TxtBox.Text + CStr(i)
		End If
		TxtBox.Text = Format(TxtBox.Text, "######0")
	End If
End Sub


look at the difference in the previous and current code

This post has been edited by thava: 01 June 2009 - 06:42 PM

Was This Post Helpful? 0
  • +
  • -

#13 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 02 June 2009 - 01:13 AM

tq for the coding it very help ful
ya since as u know i am doing some coding stuff
if i wan to decode. can these step help me

first i input my text in to a textbox
then i press the a command button that i have write the step in it
this will direct decode the code to the textbox that i designated.

but i wan to have it show directly at the box that i wan all the data from each text box that have been decode to it

what should i do?
can do like this ?

Private Sub Command1_Click()
Text1.Text = Val(Input1.Text) + 10
Text2.Text = Val(Input1.Text) + 20
end
end sub

public sub addtext()
Text3.text= text1.text + Vbnewline + text2.text
end sub

i have try it can be done but the only thing is i have to click at the text3 box and press enter before the code
appear at the textbox3.

got anyway to direct show all the data when i input the code into the box and press the command button

tq

and another question is it possible to retrive any row specifically from an access or an excel with just coding?
and also is there code to limit the number of row that i wan to retrive and which row to begin to retrive or something similar
Was This Post Helpful? 0
  • +
  • -

#14 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,599
  • Joined: 17-April 07

Re: How to do conversion certain munber to code

Posted 03 June 2009 - 02:14 AM

just call the addtext procedure in the command 1_click event

there is lot tutorial around here to solve your question just search for that tutorials
Was This Post Helpful? 0
  • +
  • -

#15 mengonn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 28-May 09

Re: How to do conversion certain munber to code

Posted 06 June 2009 - 10:45 PM

hi thava,
i think the code u give me got some error

EG:
1) when i enter 5 it show 0 (correct)
2) follow by 1 it show this (51) (incorrect) as it suppose to show 01 instead of 51)


got any further solution
and about the previous question, i have try search the tutorial, i will say my finding is not very productive

you see i manage to get tutorial about how to connect a database,
but when i try to connect a text box using a data object (i try to set the system to excel but it say cant find ISAM if not mistaken. so can u give any advice?

by the way is the a code that can do this when i update my date in access
(data1.recordset.update) as i press it i will send data to an excel file that will do the calculation that i need?

last question can excel do this thing: i will need excel to do summary with certain code, not all of it, may be 1k or 2k of the data.
so can the excel be coded so that i will only take the requested data only ( EG: from april to may(i have put id in it. so i will look like calling id then calculate base on that row.)

pls help tq for all the previous help :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2