Share

Parsing

Avatar

Hello Fellow Programmers,



Need some help with handling strings.



I need to parse every nth character from a string/textbox control in Visual Basic.



Any suggestions or links?

Avatar

While looking for programmers I would like a routine that will count the pairs from an output of lotto632 and or lotwon to see what pairs or triples of numbers were generated by these programs for 5/ 39 and or 6/52 games , to this end we could see if a given set of two or three is most likely to hit sets could be used in a wheeling program.



BigJer

Todd's avatar - Cylon 200.jpg
Quote:Originally posted by Sedertree on January 7, 2005


Hello Fellow Programmers,

Need some help with handling strings.

I need to parse every nth character from a string/textbox control in Visual Basic.

Any suggestions or links?



To parse every 5th character of strString:

for x = 1 to len(strString) step 5
  strChar = mid(strString, x, 1)
  'Do whatever with strChar
next

(Or change the x = 1 to x = 5 to start at the 5th character instead of the first character.)

Johnny5's avatar - japheth

Good work Todd.



I would though make sure he knows to capture information in the "Text Box" in VB.



It will look similar but like this:



strString = this.text1.value



for x = 1 to len(strString) step 5

strChar = mid(strString, x, 1)

'Do whatever with strChar

next



If you have a variable without value it won't work. Unless you specify the "this.text1.value" in place of the "strString" variable.



Anyway, Todd gave you the base of the code. I just wanted to add in case you forget to assign the value.



Hey it can happen to anyone.



Laters and good luck.

Avatar

Thanks Guys,

I haven't put this specific code to work yet.  The "all positions" digit tabulator code I finished this morning for the position frequencies has swollen my app to 1.14MB.  Oh well, at least I'm generating the bar graph array now.

I've had to start compiling in safe mode just to cut the time down to 5 minutes.  I'll probably start parsing specific positions this weekend.  I'll put up a screenshot when I finish this phase of programming.

Todd's avatar - Cylon 200.jpg
Quote:Originally posted by Johnny5 on January 7, 2005


Good work Todd.

I would though make sure he knows to capture information in the "Text Box" in VB.

It will look similar but like this:

strString = this.text1.value

for x = 1 to len(strString) step 5
strChar = mid(strString, x, 1)
'Do whatever with strChar
next

If you have a variable without value it won't work. Unless you specify the "this.text1.value" in place of the "strString" variable.

Anyway, Todd gave you the base of the code. I just wanted to add in case you forget to assign the value.

Hey it can happen to anyone.

Laters and good luck.



I kinda figured he would know to put a value in the string variable.  It was just a code fragment.
Avatar

Todd, he's the man. If he can't code it, no one can.

Avatar

Yea,

I knew about .value, but good looking out.  And thanks for the footnotes about the variable values for x.  I'm sure that would have been my next question when the code wouldn't recognize the digits in the first and/or second numbers of the string.

Forgot to post that last part earlier, was in a hurry....

Avatar

Forgot that I don't need Val(text1.text) because I have a user-defined function that handles the digits as integers. Which generates the frequency chart(graphics array). Anyway the code is working as;

        Dim digitString As String

        Dim strChar As String



Private Sub FourthPosit4_Click()

        digitString = Text1.Text   '(String of winning numbers)

       

        For x = 4 To Len(digitString) Step 5

        strChar = Mid(digitString, x, 1)

        'Add strChar to Digit Textbox String

        Text3.Text = Text3.Text + strChar '(String of parsed digits)

Next x



This sub is parsing the fourth digit from a delimited string of past winning Pick-4 numbers and putting them together into text3.text



Thanks again for your help. I'll post a screenshot after I get these specific positions to generate (.visible) the graphic array. Right now the "All Positions" click dvent is the only one doing this.

Avatar
retxx's avatar - mrthumbs

hi will you allow us to try it out in our own states when it is ready? Thanks

LANTERN's avatar - kilroy 28_173_reasonably_small.jpg

So it seems that you are working on a new better version of your Wheeling system.

That's very good.

Good luck.

 

Avatar

Retxx,



Yes.... As you can see, it is DonationWare. I'm sure there will be some "software freeloaders" out there. But I'm hoping some people will enjoy it enough to reward me for my time and for making them some money.



Lantern,



The Distribution Chart shown in the screenshot is fully interactive and easy to understand. A major improvement over the freeware version. The "Actual" and "Sorted" buttons have not been coded yet. You might be asking yourself "Why the buttons?" I don't want to give the secret away just yet.



I'm breathing a sigh of relief since the chart was a major undertaking. Did it all myself with a little help from my friends in the tough spots.



Back to work....

Sandy K's avatar - graphic pub.jpg

George, are you going to fix that .ocx file thing?  Too confusing how to fix...I deleted the whole thing because I ain't fussing!!

retxx's avatar - mrthumbs

george,are you saying that you released it? If so where?Thanks

Last4Show page 2Page 3 of 7
Avatar

Got the bugs/logic errors worked out for the side-by-side drawfile comparison function tonight. Decided to add a statusbar to the bottom of the listboxes that will show how many entries there are in each drawfile that you are comparing/contemplating for integration. That should help to track down where the missing entries are in each, I'll do the code for those totals in the morning.



I'm not really teasing



I want to keep a running log of the progress as it happens. I'm not a platinum member yet so I don't want to put this in my Blog and have it disappear after awhile. Besides, maybe some of these functions I post can help another lottery programmer.



I should have the drawfile editor completed to my satisfaction by the end of this weekend if all goes well.



The next phase of programming will be to make sure that all the functions on the mainform are working properly. I had fixed the Spike/Trough Filters before, but had not burned a copy of the sourcecode before my last system crash. Soooooo I will have to fix them again and burn it this time. BTW I burned a copy tonight of my recent work. I'll try to do this every few days.



As for Beta-Testers, I have one fellow who does this for me. I would like to have one or two more who have have already worked with SMWS before and are comfortable with the concept. It probably will take the better part of this year before I have it ready for Beta-Testing.

Avatar

Back at it again this weekend....



Had an idea for a "Drawfile Converter" to add to my Drawfile Editor arsenal. Here is the format SMWS uses.



01/21/2005 211

01/20/2005 424

01/19/2005 925

01/18/2005 225



Lotterypost Uses;



Fri, Jan 21, 2005     2-1-1

Thu, Jan 20, 2005     4-2-4

Wed, Jan 19, 2005     9-2-5

Tue, Jan 18, 2005     2-2-5



How many different formats can we come up with to convert to SMWS format.

Todd's avatar - Cylon 200.jpg

George:

Just use Excel.  It is AWESOME at quickly converting large amounts of data, and is equally awesome in its copy & paste abilities.  Those dates would convert in a snap.

Avatar

Todd,



I'm ashamed to admit it, but I'm really not that versed in Excel. I read somewhere that you can use spreadsheets? in VB. I really haven't done a lot of research into that yet.



My goal with the converter is to allow the user to use "any" source for their drawfile data. There has to be a permutation limit on how many ways the source can display that information.



Like Michigan for example has gif's along with the data. But if you copy and paste - including gif's - to notepad it comes out like this.



      Tue. Jan 18, 2005       225

     Wed. Jan 19, 2005      925

     Thu. Jan 20, 2005      424

     Fri. Jan 21, 2005      211



I'd like to develop an algorithm/parser that can deal with any format and convert it to a form that SMWS can recognize. The trick is to find out what format the .txt file is in and then sub to the correct parser and convert it.



I know some states (MI incl.) append their drawfile data to the bottom of the list. Which means that I'll have to sort the list by date. It will be a challenge I'm sure.



As for me, I download drawfiles for LottoBuster and open them in VB. Then I have to copy the data to Ultraedit32 and delete the columns I don't need. A whole lot of extra steps that I think needs simplifying.



BTW, LottoBuster uses;



[09/04/2004 Evening    04 07 06]

[09/03/2004 Evening    05 05 09]

[09/02/2004 Evening    00 00 04]

[09/01/2004 Evening    03 03 08]

Todd's avatar - Cylon 200.jpg

George,

Creating a good parser is a huge challenge and can really suck the life out of you.  If you're up for a good challenge, then go for it.

By the way, if you're not versed in regular expressions, this may be a good opportunity to learn.  They are monumentally powerful, but syntactically difficult to learn.  The good thing about regex's is that there is a way to parse just about anything using them, but you'll find that creating the regex string is an art form.

You may want to search the net for pre-written VB functions for parsing dates -- something that will look for just about any date format.  Parsing the numbers should be relatively easy.

Good luck!

Berley's avatar - animal bear.jpg

Sedertree check the draw files in versebet they can be saved as excell or text files.

hope this helps.

retxx's avatar - mrthumbs

george question; I got a pop up saying runtime error 380 invalid property value. i went to the website to the ocx's and looked at the entire list to download and could not find what to download. Can you help by pointing it out

Avatar

Retxx,



The error "invalid property value" is not OCX related. It would help to know what you are doing when this error comes up. It could be one of many things - all user defined "logic errors".



The first thought is that you are using a setting that doesn't exist or is out of range. Since, I believe, all the settings have limits to what values the user can assign. You might have an invalid setting in a .sed file. Like trying to assign a sum total setting higher than 27 for the pick-3. Or using a string (twenty-seven) where an integer (27) should go.



I'm not there at your computer so I can't do your thinking for you. You'll have to isolate the cause and let me know what you're doing wrong.



retxx's avatar - mrthumbs

as far as I know it happens when i hit the reset button and I try and load another file such as one I built from notepad. Does this make any sense? as far as the profile I keep all in range as far as I can see. thanks

Avatar

Retxx,



"load another file".....



Do you mean a .sed profile or a drawfile.

Avatar

Worked most of the night and succeeded in determining that drawfiles were either in Lottobusters' Pick-3 or Pick-4 formats. Haven't started the actual conversions yet to SMWS. I have a handful of formats that I'll need to analyze and find out "what they are" before I start doing conversions.



Some formats can be converted and some cannot. What's exciting is that some official lottery websites archives can be converted as well. Here is a list of those I can convert;



VersaBet:

LottoBuster:

LotteryPost:

Michigan Lottery:

Arizona Lottery:

California Lottery:

Florida Lottery:

Idaho Lottery:

Minnesota Lottery:

New Jersey Lottery: (Combined Only)

New York Lottery:

Texas Lottery:

Tri-State Lottery:



That's all for tonight.....

retxx's avatar - mrthumbs

I think when I take notepad and save as and add it to sedertree it is a text file,right?

Avatar

Yes, notepad saves as a .txt file. Also check that your format is correct.



00/00/0000<sp>000

Avatar

Getting ready for work....



So far I have the drawfile converter recognizing;



VersaBet, LottoBuster, LotteryPost and Michigan Lottery Formats. Tonight after work I'll work on some more of the formats listed in my previous post.



It will be nice to get all these formats recognized so I can work on the actual conversions.



This will be nice for non-standard members of lotterypost to convert Todd's drawfile format into a format that SMWS will recognize.



Are there any other lottery software drawfiles that someone would like to convert? If so, copy and paste about seven draws for the Pick-3 and Pick-4 as long as they are in .txt format source. Let me know what software or source they come from and I'll see if I can convert them as well.



Depending on interest, I could also convert drawfiles from one format to another. VersaBet and LottoBuster are moot since users can download their drawfiles. Maybe you might want to convert Lotterypost Format to another software's format. Or SMWS to another software's format.



Thanks,

Developer's avatar - logo2 small.jpg

On the conversion side of things it gets tricky, I know been there done that as they say.

Points to think about and look out for

Dates (The real hurdle in your quest)

dd/mm/yyyy, or dd/mm/yy or mm/dd/yyyy or dd/mm/yyyy

This can be a real headache.

Parsing strings

tip use IsNumeric() , IsNull(), IsDate()

Also use the split function

I wrote a little function to split space and comma strings for you

Function SplitString(WhatString As String)
Dim SplitStr() As String
Dim SplitCount As Double
Dim I As Double
    SplitCount = 0
   
If SplitCount <= 0 Then SplitStr = Split(WhatString, " ", 20, vbTextCompare): SplitCount = UBound(SplitStr)
If SplitCount <= 0 Then SplitStr = Split(WhatString, ",", 20, vbTextCompare): SplitCount = UBound(SplitStr)


    For I = 0 To SplitCount ' Loop through each split
        If IsDate(SplitStr(I)) Then MsgBox "The date is " & SplitStr(I)
        If IsNumeric(SplitStr(I)) Then MsgBox "The number is " & Val(SplitStr(I))
    Next I
   
End Function

Welcome Guest

Your last visit: Sat, May 21, 2022, 10:34 am

Log In

Log InCancel

Forgot your username?

Forgot your password?