20200420使用VB6.0求33选6的全组合数(解决变长字符串超过1MB之后写入的问题)

本文主要是介绍20200420使用VB6.0求33选6的全组合数(解决变长字符串超过1MB之后写入的问题),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

20200420使用VB6.0求33选6的全组合数(解决变长字符串超过1MB之后写入的问题)

 

最近需要求组合数(买双色球生成号码用^_)
以前在大学专门学习过VB6.0,今后会迁移到VC6.0。
预计会在2020.5.1强化一下MFC,就可以了!

 

我也不知道边长字符串到底写入多少回崩溃。(现阶段人也不年轻了,也没有这么多时间去研究了!有兴趣的同学跟帖告诉我一下,在此谢过了!)

 

 

VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   12825
   ClientLeft      =   450
   ClientTop       =   615
   ClientWidth     =   14535
   LinkTopic       =   "Form1"
   ScaleHeight     =   12825
   ScaleWidth      =   14535
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   12255
      Left            =   600
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Top             =   360
      Width           =   6135
   End
   Begin VB.CommandButton Command2 
      Caption         =   "求33选6的全组合数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   8040
      TabIndex        =   0
      Top             =   5520
      Width           =   4935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()

End Sub

Private Sub Command2_Click()
    Dim h1%, h2%, h3%, h4%, h5%, h6%
    Dim h6sum%
    
    Dim i%
    Dim j%
    Dim temp%
    Dim count%
    Dim guangyayuan(35) As Integer
    Dim wutongshan(35) As Integer
    
    Dim guangyayuan6(35) As Integer
    Dim hong1%, hong2%, hong3%, hong4%, hong5%, hong6%
    
    Dim strWj As String
    
    
    
    
'    For hong1 = 1 To 10
'        'For hong2 = hong1 To 11
'        For hong2 = hong1 + 1 To 11
'            For hong3 = hong2 + 1 To 12
'                For hong4 = hong3 + 1 To 13
'                    For hong5 = hong4 + 1 To 14
'                        For hong6 = hong5 + 1 To 15
    For hong1 = 1 To 28
        For hong2 = hong1 + 1 To 29
            For hong3 = hong2 + 1 To 30
                For hong4 = hong3 + 1 To 31
                    For hong5 = hong4 + 1 To 32
                        For hong6 = hong5 + 1 To 33
                            'Text2 = Text2 & hong1 & "," & hong2 & "," & hong3 & "," & hong4 & "," & hong5 & "," & hong6 & vbCrLf
                            strWj = strWj & hong1 & "," & hong2 & "," & hong3 & "," & hong4 & "," & hong5 & "," & hong6 & vbCrLf
                        Next hong6
                    Next hong5
                Next hong4
            Next hong3
        Next hong2
    Next hong1
    
    
    
    
    'Close #2
    
    'Open "d:\ScoreW2.txt" For Output As #1
    'Open "d:\求12选3的全组合数.txt" For Output As #1
    Open "d:\求33选6的全组合数.txt" For Output As #1
    'Write #1, Text2
    Write #1, strWj
    Close #1
End Sub
 

 

 

我这里采用了一个最简单粗暴的做法,将每一组的六个号码立即写入磁盘。(具体交给操作系统了)

求33选6的全组合数.txt 大概23MB。

大致内容:

 

"1,2,3,4,5,6
"
"1,2,3,4,5,7
"
"1,2,3,4,5,8
"
"1,2,3,4,5,9
"
"1,2,3,4,5,10
"
"1,2,3,4,5,11
"
"1,2,3,4,5,12
"
"1,2,3,4,5,13
"
"1,2,3,4,5,14
"
"1,2,3,4,5,15
"
"1,2,3,4,5,16
"
"1,2,3,4,5,17
"
"1,2,3,4,5,18
"
"1,2,3,4,5,19
"
"1,2,3,4,5,20
"
"1,2,3,4,5,21
"
"1,2,3,4,5,22
"
"1,2,3,4,5,23
"
"1,2,3,4,5,24
"
"1,2,3,4,5,25
"
"1,2,3,4,5,26

 

……

 

"
"25,28,30,31,32,33
"
"25,29,30,31,32,33
"
"26,27,28,29,30,31
"
"26,27,28,29,30,32
"
"26,27,28,29,30,33
"
"26,27,28,29,31,32
"
"26,27,28,29,31,33
"
"26,27,28,29,32,33
"
"26,27,28,30,31,32
"
"26,27,28,30,31,33
"
"26,27,28,30,32,33
"
"26,27,28,31,32,33
"
"26,27,29,30,31,32
"
"26,27,29,30,31,33
"
"26,27,29,30,32,33
"
"26,27,29,31,32,33
"
"26,27,30,31,32,33
"
"26,28,29,30,31,32
"
"26,28,29,30,31,33
"
"26,28,29,30,32,33
"
"26,28,29,31,32,33
"
"26,28,30,31,32,33
"
"26,29,30,31,32,33
"
"27,28,29,30,31,32
"
"27,28,29,30,31,33
"
"27,28,29,30,32,33
"
"27,28,29,31,32,33
"
"27,28,30,31,32,33
"
"27,29,30,31,32,33
"
"28,29,30,31,32,33
"
 

 

 

读者可能很容易看到会多一个英文的引号,这个怎么解决呢?

 

https://zhidao.baidu.com/question/7939187.html
用vb读写文件时,写成的文本文件每行都有双引号,怎么才能把双引号去掉啊?
怎样写的文件,才能没有双引号啊?

wangtk1982  
2006-05-30
使用print语句 不用用write
 本回答由提问者推荐
 3     评论(1) 分享 举报 

monkywin  
2006-05-30
用print写入文件。
用input读取文本。

 

 

 

修正之后:

VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   12825
   ClientLeft      =   450
   ClientTop       =   615
   ClientWidth     =   14535
   LinkTopic       =   "Form1"
   ScaleHeight     =   12825
   ScaleWidth      =   14535
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   12255
      Left            =   600
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Top             =   360
      Width           =   6135
   End
   Begin VB.CommandButton Command2 
      Caption         =   "求33选6的全组合数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   26.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   8040
      TabIndex        =   0
      Top             =   5520
      Width           =   4935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()

End Sub

Private Sub Command2_Click()
    Dim h1%, h2%, h3%, h4%, h5%, h6%
    Dim h6sum%
    
    Dim i%
    Dim j%
    Dim temp%
    Dim count%
    Dim guangyayuan(35) As Integer
    Dim wutongshan(35) As Integer
    
    Dim guangyayuan6(35) As Integer
    Dim hong1%, hong2%, hong3%, hong4%, hong5%, hong6%
    
    Dim strWj As String
    strWj = ""
    
    Open "d:\求33选6的全组合数.txt" For Output As #1
    
    
    

    For hong1 = 1 To 28
        For hong2 = hong1 + 1 To 29
            For hong3 = hong2 + 1 To 30
                For hong4 = hong3 + 1 To 31
                    For hong5 = hong4 + 1 To 32
                        For hong6 = hong5 + 1 To 33
                            'Text2 = Text2 & hong1 & "," & hong2 & "," & hong3 & "," & hong4 & "," & hong5 & "," & hong6 & vbCrLf
                            'strWj = strWj & hong1 & "," & hong2 & "," & hong3 & "," & hong4 & "," & hong5 & "," & hong6 & vbCrLf
                            strWj = strWj & hong1 & "," & hong2 & "," & hong3 & "," & hong4 & "," & hong5 & "," & hong6
                            
                            'Write #1, strWj
                            Print #1, strWj
                            strWj = ""
                        Next hong6
                    Next hong5
                Next hong4
            Next hong3
        Next hong2
    Next hong1
    
    
    
    
    'Close #2
    
    'Open "d:\ScoreW2.txt" For Output As #1
    'Open "d:\求12选3的全组合数.txt" For Output As #1
    'Open "d:\求33选6的全组合数.txt" For Output As #1
    'Write #1, Text2
    
    'Write #1, strWj
    Close #1
End Sub
 

 

 

 

1,2,3,4,5,6
1,2,3,4,5,7
1,2,3,4,5,8
1,2,3,4,5,9
1,2,3,4,5,10
1,2,3,4,5,11
1,2,3,4,5,12
1,2,3,4,5,13
1,2,3,4,5,14
1,2,3,4,5,15
1,2,3,4,5,16
1,2,3,4,5,17
1,2,3,4,5,18
1,2,3,4,5,19
1,2,3,4,5,20
1,2,3,4,5,21
1,2,3,4,5,22
1,2,3,4,5,23
1,2,3,4,5,24
1,2,3,4,5,25
1,2,3,4,5,26
1,2,3,4,5,27
1,2,3,4,5,28
1,2,3,4,5,29

……

25,28,29,31,32,33
25,28,30,31,32,33
25,29,30,31,32,33
26,27,28,29,30,31
26,27,28,29,30,32
26,27,28,29,30,33
26,27,28,29,31,32
26,27,28,29,31,33
26,27,28,29,32,33
26,27,28,30,31,32
26,27,28,30,31,33
26,27,28,30,32,33
26,27,28,31,32,33
26,27,29,30,31,32
26,27,29,30,31,33
26,27,29,30,32,33
26,27,29,31,32,33
26,27,30,31,32,33
26,28,29,30,31,32
26,28,29,30,31,33
26,28,29,30,32,33
26,28,29,31,32,33
26,28,30,31,32,33
26,29,30,31,32,33
27,28,29,30,31,32
27,28,29,30,31,33
27,28,29,30,32,33
27,28,29,31,32,33
27,28,30,31,32,33
27,29,30,31,32,33
28,29,30,31,32,33
 

 

 

 

 

 

 

 

 

 

 

这篇关于20200420使用VB6.0求33选6的全组合数(解决变长字符串超过1MB之后写入的问题)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/622254

相关文章

如何使用Docker部署FTP和Nginx并通过HTTP访问FTP里的文件

《如何使用Docker部署FTP和Nginx并通过HTTP访问FTP里的文件》本文介绍了如何使用Docker部署FTP服务器和Nginx,并通过HTTP访问FTP中的文件,通过将FTP数据目录挂载到N... 目录docker部署FTP和Nginx并通过HTTP访问FTP里的文件1. 部署 FTP 服务器 (

MySQL 日期时间格式化函数 DATE_FORMAT() 的使用示例详解

《MySQL日期时间格式化函数DATE_FORMAT()的使用示例详解》`DATE_FORMAT()`是MySQL中用于格式化日期时间的函数,本文详细介绍了其语法、格式化字符串的含义以及常见日期... 目录一、DATE_FORMAT()语法二、格式化字符串详解三、常见日期时间格式组合四、业务场景五、总结一、

Python中配置文件的全面解析与使用

《Python中配置文件的全面解析与使用》在Python开发中,配置文件扮演着举足轻重的角色,它们允许开发者在不修改代码的情况下调整应用程序的行为,下面我们就来看看常见Python配置文件格式的使用吧... 目录一、INI配置文件二、YAML配置文件三、jsON配置文件四、TOML配置文件五、XML配置文件

Go使用pprof进行CPU,内存和阻塞情况分析

《Go使用pprof进行CPU,内存和阻塞情况分析》Go语言提供了强大的pprof工具,用于分析CPU、内存、Goroutine阻塞等性能问题,帮助开发者优化程序,提高运行效率,下面我们就来深入了解下... 目录1. pprof 介绍2. 快速上手:启用 pprof3. CPU Profiling:分析 C

springboot3.4和mybatis plus的版本问题的解决

《springboot3.4和mybatisplus的版本问题的解决》本文主要介绍了springboot3.4和mybatisplus的版本问题的解决,主要由于SpringBoot3.4与MyBat... 报错1:spring-boot-starter/3.4.0/spring-boot-starter-

MySQL InnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据

《MySQLInnoDB引擎ibdata文件损坏/删除后使用frm和ibd文件恢复数据》mysql的ibdata文件被误删、被恶意修改,没有从库和备份数据的情况下的数据恢复,不能保证数据库所有表数据... 参考:mysql Innodb表空间卸载、迁移、装载的使用方法注意!此方法只适用于innodb_fi

Python中conda虚拟环境创建及使用小结

《Python中conda虚拟环境创建及使用小结》本文主要介绍了Python中conda虚拟环境创建及使用小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们... 目录0.前言1.Miniconda安装2.conda本地基本操作3.创建conda虚拟环境4.激活c

Spring中@Lazy注解的使用技巧与实例解析

《Spring中@Lazy注解的使用技巧与实例解析》@Lazy注解在Spring框架中用于延迟Bean的初始化,优化应用启动性能,它不仅适用于@Bean和@Component,还可以用于注入点,通过将... 目录一、@Lazy注解的作用(一)延迟Bean的初始化(二)与@Autowired结合使用二、实例解

SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)

《SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)》本文介绍了如何在SpringBoot项目中使用Jasypt对application.yml文件中的敏感信息(如数... 目录SpringBoot使用Jasypt对YML文件配置内容进行加密(例:数据库密码加密)前言一、J

Spring Boot 中正确地在异步线程中使用 HttpServletRequest的方法

《SpringBoot中正确地在异步线程中使用HttpServletRequest的方法》文章讨论了在SpringBoot中如何在异步线程中正确使用HttpServletRequest的问题,... 目录前言一、问题的来源:为什么异步线程中无法访问 HttpServletRequest?1. 请求上下文与线