Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Request] - Convert Excel formula to VB6 Code
#1
Ok, so I posted this in HF, and did not even get 1 reply. So hoping to get some support here in SF Huh

=========== Copy + Paste from HF ==============

Well, with the little knowledge I have in VBA, I made a small form that could validate a certain number through input in a text box. But being not that good in VBA, I used the excel sheet to do the formula, and the form pulling the results from the excel sheet. I then hid the sheet, and allowed the form to execute.

Now, I need to give out this small "program" to a couple of my clients, but obviously don't want to look like an idiot for sending it in an excel sheet. So I need to convert this to .exe with the help of VB6.

Well, I can move around a VB6 area pretty much smoothly, but I am not that much into coding. So if someone here could help me, or point me in the right direction, I am pretty much sure I can grasp what needs to be done.

Basically, it's just a single input, and 3 outputs (valid number or not, age, date of birth) based on the input.

The 3 output excel formulas are (where D11 is the input cell value),

Code:
=IF(D11="","Please Enter Number",IF(LEN(D11)=12,IF((11-MOD((LEFT(D11,1)*2)+(MID(D11,2,1)*1)+(MID(D11,3,1)*6)+(MID(D11,4,1)*3)+(MID(D11,5,1)*7)+(MID(D11,6,1)*9)+(MID(D11,7,1)*10)+(MID(D11,8,1)*5)+(MID(D11,9,1)*8)+(MID(D11,10,1)*4)+(MID(D11,11,1)*2),11))=VALUE(RIGHT(D11,1))=TRUE,D11&" is a Valid Civil ID", D11&" is an Invalid Civil ID Number"),"Please check number of Digits"))



Code:
=IF(AND(LEN(D11)=12,LEFT(D11,1)="2",(11-MOD((LEFT(D11,1)*2)+(MID(D11,2,1)*1)+(MID(D11,3,1)*6)+(MID(D11,4,1)*3)+(MID(D11,5,1)*7)+(MID(D11,6,1)*9)+(MID(D11,7,1)*10)+(MID(D11,8,1)*5)+(MID(D11,9,1)*8)+(MID(D11,10,1)*4)+(MID(D11,11,1)*2),11)=VALUE(RIGHT(D11,1))=TRUE)),"Date of Birth : "&TEXT(MID(D11,6,1)&MID(D11,7,1)&"/"&MID(D11,4,1)&MID(D11,5,1)&"/"&"19"&MID(D11,2,1)&MID(D11,3,1),"dd/mm/yyyy"),IF(AND(LEN(D11)=12,LEFT(D11,1)="3",(11-MOD((LEFT(D11,1)*2)+(MID(D11,2,1)*1)+(MID(D11,3,1)*6)+(MID(D11,4,1)*3)+(MID(D11,5,1)*7)+(MID(D11,6,1)*9)+(MID(D11,7,1)*10)+(MID(D11,8,1)*5)+(MID(D11,9,1)*8)+(MID(D11,10,1)*4)+(MID(D11,11,1)*2),11)=VALUE(RIGHT(D11,1))=TRUE)),"Date of Birth : "&TEXT(MID(D11,6,1)&MID(D11,7,1)&"/"&MID(D11,4,1)&MID(D11,5,1)&"/"&"20"&MID(D11,2,1)&MID(D11,3,1),"dd/mm/yyyy"),""))



Code:
=IF(AND(LEN(D11)=12,LEFT(D11,1)="2",(11-MOD((LEFT(D11,1)*2)+(MID(D11,2,1)*1)+(MID(D11,3,1)*6)+(MID(D11,4,1)*3)+(MID(D11,5,1)*7)+(MID(D11,6,1)*9)+(MID(D11,7,1)*10)+(MID(D11,8,1)*5)+(MID(D11,9,1)*8)+(MID(D11,10,1)*4)+(MID(D11,11,1)*2),11)=VALUE(RIGHT(D11,1))=TRUE)),"Age : "&YEAR(NOW())-YEAR(DATE("19"&MID(D11,2,1)&MID(D11,3,1),MID(D11,4,1)&MID(D11,5,1),MID(D11,6,1)&MID(D11,7,1))),IF(AND(LEN(D11)=12,LEFT(D11,1)="3",(11-MOD((LEFT(D11,1)*2)+(MID(D11,2,1)*1)+(MID(D11,3,1)*6)+(MID(D11,4,1)*3)+(MID(D11,5,1)*7)+(MID(D11,6,1)*9)+(MID(D11,7,1)*10)+(MID(D11,8,1)*5)+(MID(D11,9,1)*8)+(MID(D11,10,1)*4)+(MID(D11,11,1)*2),11)=VALUE(RIGHT(D11,1))=TRUE)),"Age : "&YEAR(NOW())-YEAR(DATE("20"&MID(D11,2,1)&MID(D11,3,1),MID(D11,4,1)&MID(D11,5,1),MID(D11,6,1)&MID(D11,7,1))),""))

Please help me convert the above 3 formulas to show output on a VB6 form, where D11 will be a text box.

Here is the form that I use through Excel, it will help give a better idea Smile

[Image: 67073314.jpg]

It would be great if you guys could atleast point me to the right tutorial for this kind of work. Thanks in advance :biggrin:
[Image: IKILLUNEW.jpg]
Reply


Messages In This Thread
[Request] - Convert Excel formula to VB6 Code - by Carb0n F1ber - 04-08-2010, 01:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  vb6.0 SSTab control disappeared DanB 0 1,214 12-29-2012, 10:24 AM
Last Post: DanB
  Get Country Code In 1 Line Of Code. wchar_t 13 4,189 11-28-2012, 06:49 AM
Last Post: Cubs
  [HELP][VB6] Comparing md5/file size? Cloud203 5 2,187 02-04-2012, 02:47 PM
Last Post: Denny Crane
  VB6 | PickYourShow0.1 BETA BreShiE 29 6,366 01-11-2012, 02:44 AM
Last Post: BreShiE
  [VB6] Shopping List BreShiE 3 1,410 12-30-2011, 07:51 PM
Last Post: BreShiE

Forum Jump:


Users browsing this thread: 1 Guest(s)