Hi All,
I have some problem with vb6 code.
I have a data contain :
:25:0186350587
:25:186350587
:25:86350587
:25:6350587
:25:350587
:25:50587
:25:587
:25:87
:25:7
I want it to insert zero number after :25: , but the number after :25: is always has to be 10 digit. So it would be :
:25:0186350587
:25:0186350587
:25:0086350587
:25:0006350587
:25:0000350587
:25:0000050587
:25:0000000587
:25:0000000087
:25:0000000007
I have a code in vb6 but it only insert two digit of zero number, so it would be :
:25:000186350587 (more than 10 digit)
:25:00186350587 (more than 10 digit)
:25:0086350587 (10 digit)
:25:006350587 (less than 10 digit)
:25:00350587 (less than 10 digit)
:25:0050587 (less than 10 digit)
:25:00587 (less than 10 digit)
:25:0087 (less than 10 digit)
:25:007 (less than 10 digit)
this is my code with textbox and command : -
Private Sub cmdProses_Click()
-
Dim txt
-
txt = TextBox.Text
-
If InStr(1, TextBox.Text, ":25:") > 0 Then
-
TextBox.Text = Replace(txt, ":25:", ":25:00")
-
End If
-
End Sub
-
Would you like to help me with the new code please
Thank you
Andi.
FYI
The link below is the complete of my program and the data that I want to change
http://docs.google.com/leaf?id=0B8HOcoYLae3IMTU5YjMxNjUtNjg3MS00MjQwLTkwZ mUtNjI2M2ZiMDNkMmM2&sort=name&layout=list&num=50
I think this will do the job= - Private Sub cmdProses_Click()
-
Dim ARRAYTEXT() As String
-
Dim ARRAYTEXTidx As Integer
-
ARRAYTEXT = Split(TextBox.Text, vbCrLf)
-
TextBox.Text = ""
-
For ARRAYTEXTidx = LBound(ARRAYTEXT) To UBound(ARRAYTEXT) - 1
-
If (Left(ARRAYTEXT(ARRAYTEXTidx), 4) = ":25:" Or _
-
Left(ARRAYTEXT(ARRAYTEXTidx), 4) = ":28:") And _
-
Len(Mid(ARRAYTEXT(ARRAYTEXTidx), 5)) < 10 Then
-
TextBox.Text = TextBox.Text & Left(ARRAYTEXT(ARRAYTEXTidx), 4) & _
-
Format(Mid(ARRAYTEXT(ARRAYTEXTidx), 5), "0000000000") & vbCrLf
-
Else
-
TextBox.Text = TextBox.Text & ARRAYTEXT(ARRAYTEXTidx) & vbCrLf
-
End If
-
Next
-
End Sub
PS:
I had also so questions with Your code:
- Why "New" in the menu when You will open a new file or Exit?
- Why "Close" button when You have "Exit" in the menu ?
I have taken the liberty to do some modifications (see attachment).
So if You want to use them, be my guest.
18 3087
I hope this will help You: (see also attachment) - Private Sub Command1_Click()
-
Dim ARRAYTEXT1() As String
-
Dim LINEidx As Integer
-
Dim TEXT1LINE As String
-
Dim TEXT1LINELAST As String
-
Dim TEMPTEXT2 As String
-
ARRAYTEXT1 = Split(Text1.Text, vbNewLine)
-
For LINEidx = 1 To UBound(ARRAYTEXT1)
-
TEXT1LINE = ARRAYTEXT1(LINEidx)
-
TEXT1LINELAST = Mid(TEXT1LINE, 5)
-
If InStr(TEXT1LINE, ":25:") Then
-
If Len(TEXT1LINELAST) > 10 Then
-
TEMPTEXT2 = Mid(TEXT1LINE, Len(TEXT1LINE) - 9)
-
ElseIf Len(TEXT1LINELAST) = 10 Then
-
TEMPTEXT2 = TEXT1LINELAST
-
Else
-
Select Case Len(TEXT1LINELAST)
-
Case 1
-
TEMPTEXT2 = "000000000" & TEXT1LINELAST
-
Case 2
-
TEMPTEXT2 = "00000000" & TEXT1LINELAST
-
Case 3
-
TEMPTEXT2 = "0000000" & TEXT1LINELAST
-
Case 4
-
TEMPTEXT2 = "000000" & TEXT1LINELAST
-
Case 5
-
TEMPTEXT2 = "00000" & TEXT1LINELAST
-
Case 6
-
TEMPTEXT2 = "0000" & TEXT1LINELAST
-
Case 7
-
TEMPTEXT2 = "000" & TEXT1LINELAST
-
Case 8
-
TEMPTEXT2 = "00" & TEXT1LINELAST
-
Case 9
-
TEMPTEXT2 = "0" & TEXT1LINELAST
-
End Select
-
End If
-
End If
-
Text2.Text = Text2.Text & ":25:" & TEMPTEXT2 & vbNewLine
-
Next
-
End Sub
PS:
I can't download Your attachment with the program and the data.
If necessary in the future, please ZIP it and attach it in Bytes.
As on TWO other sites... "Format" it out... -
Dim My1stArray() As String, My2ndArray() As String, S As String
-
Dim LB As Integer, UB As Integer, LoopCnt As Integer
-
-
S = ":25:0186350587,:25:186350587,:25:86350587,:25:6350587,:25:350587,:25:50587,:25:587,:25:87,:25:7"
-
-
My1stArray = Split(S, ",")
-
-
LB = LBound(My1stArray)
-
UB = UBound(My1stArray)
-
-
For LoopCnt = LB To UB
-
-
My2ndArray = Split(My1stArray(LoopCnt), ":25:")
-
Debug.Print ":25:" & Format(My2ndArray(1), "0000000000")
-
-
Next LoopCnt
-
Good Luck
But the number is not always just :
":25:0186350587,:25:186350587,:25:86350587,:25:635 0587,:25:350587,:25:50587,:25:587,:25:87,:25:7"
It can be :
":25:0006350007,:25:186350587,:25:86350587,:25:635 0587,:25:350587,:25:50587,:25:587,:25:87,:25:7"
Or :
":25:0006352207,:25:186236117,:25:86350587,:25:632 4487,:25:350587,:25:50333,:25:587,:25:87,:25:4"
and so on.
Cause I knew in VB6 I can not understand what you are trying to explain.
Maybe it will figure out by downloading the link at the above post.
Thanks anyway
Andi
Put the code in form_load and press F8 to walk through... Look at the debug window to see the results...
Good Luck
Is it possible to attach Your document in BYTES?
I get an error on Your URL link !!! "Sorry, the page (or document) you have requested is not available.
Please check the address and try again."
This is an example with "Format".
You will see : it works for the numbers in your mail which I have placed in a TextBox to test the algorithm.
If You want an example of a program with Your original datafile, please attach it in BYTES because I'm not able to download it with Your URL.
Dear all,
Finally I know why my code and your code can never be executed, the user does not ever mention that in the search string that exists between two strings. I will be working on this code to start all over again. Thanks for all your help, I really appreciate it. I'll be back again if need your help. Once again thank you all.
Thanks,
Andi
Hi again All,
This is what I've figure out :
If between ":25:" and ":28:" there is 10 character e.g 0123456789 then do nothing
If between ":25:" and ":28:" there is 9 character e.g 12345678 then replace ":25:" with ":25:0"
If between ":25:" and ":28:" there is 8 character e.g 12345678 then replace ":25:" with ":25:00"
If between ":25:" and ":28:" there is 7 character e.g 1234567 then replace ":25:" with ":25:000"
and so on.
So is there a code related to my problem?
Thanks
Andi
Is it possible to attach your document (mentioned in your first call) in BYTES so we can see with what we are starting ?
I am sorry but I can't attach anything because all blocked by office proxy.
Regards
Andi
@Andi Rustandi
This one is OK.
The data is in UNIX format (only Linefeed)!
Can I change it to DOS format (CrLF) ?
I think this will do the job= - Private Sub cmdProses_Click()
-
Dim ARRAYTEXT() As String
-
Dim ARRAYTEXTidx As Integer
-
ARRAYTEXT = Split(TextBox.Text, vbCrLf)
-
TextBox.Text = ""
-
For ARRAYTEXTidx = LBound(ARRAYTEXT) To UBound(ARRAYTEXT) - 1
-
If (Left(ARRAYTEXT(ARRAYTEXTidx), 4) = ":25:" Or _
-
Left(ARRAYTEXT(ARRAYTEXTidx), 4) = ":28:") And _
-
Len(Mid(ARRAYTEXT(ARRAYTEXTidx), 5)) < 10 Then
-
TextBox.Text = TextBox.Text & Left(ARRAYTEXT(ARRAYTEXTidx), 4) & _
-
Format(Mid(ARRAYTEXT(ARRAYTEXTidx), 5), "0000000000") & vbCrLf
-
Else
-
TextBox.Text = TextBox.Text & ARRAYTEXT(ARRAYTEXTidx) & vbCrLf
-
End If
-
Next
-
End Sub
PS:
I had also so questions with Your code:
- Why "New" in the menu when You will open a new file or Exit?
- Why "Close" button when You have "Exit" in the menu ?
I have taken the liberty to do some modifications (see attachment).
So if You want to use them, be my guest.
- PS:
-
I had also so questions with Your code:
-
- Why "New" in the menu when You will open a new file or Exit?
-
- Why "Close" button when You have "Exit" in the menu ?
Some time user want to have button to click but another user feel more comfortable with drop down menu.
But anyway thanks for the modification, it bring me new idea for the program.
Best Regards
Andi
I have done some cleanup and modifications (see attachment)
PS: if the text must put back to UNIX format: add a command with: - textbox.text=replace(textbox.text,vbcrlf,vblf)
@ggeu
Thanks ggeu,
It really works, you are doing great job.
Thanks Again,
Andi
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Svennglenn |
last post by:
I'm having problems replacing text in a
unicode string.
Here's the code:
# -*- coding: cp1252 -*-
titel = unicode("ä", "iso-8859-1")
print titel
print type(titel)
|
by: JackRazz |
last post by:
I'm trying to use Visual Studio's Find/Replace to match VB declarations. This RegEx
works fine in Regulator:
...
|
by: :\\\\derian |
last post by:
anyone know where i could find the equivalent of the find / replace windows
control for my project?
:\\derian
|
by: scorpion53061 |
last post by:
This excel find/replace code works great under Excel 2003 but bombs with an
error (pasted below the code) in Excel 2000. Can anyone suggest an
alternative to make both happy? I am using vb.net...
|
by: Mark |
last post by:
Hello,
Can anyone help me on how to find and replace text within a .txt file using
vb.net?
Any help would be greatly appreciated!
Thanks in advance.
|
by: D Brown |
last post by:
Does anyone know why my .NET development would hang / freeze when
performing a Global Find / Replace on all files? I have a large
ASP.NET VB Application. I have left the machine for 24 hours but...
|
by: Casey |
last post by:
Hello,
Can someone give me specific code to replace text on a page using
server side javascript? I need to use server-side because I need the
output to be recognized in the final HTML so that...
|
by: cewyattjr |
last post by:
In a mediumtext field I have many instances of a URL, eg:
'http://myurl.com/index.php' that I want to replace with just '/'
How can I write an update query that will update all instances of the...
|
by: John Pye |
last post by:
Hi all
I have a file with a bunch of perl regular expressions like so:
/(^|)\*(.*?)\*(|$)/$1'''$2'''$3/ #
bold
/(^|)\_\_(.*?)\_\_(|$)/$1''<b>$2<\/
b>''$3/ # italic bold...
|
by: Lengara |
last post by:
I have an Access form that will be FTPing information. The FTP info will be using a text file located on the hard drive. This text file will have symbolics in it that will be replaced by entries on...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |