Visual Basic

本文介绍了VisualBasic的基本概念,展示了如何使用VisualStudio创建控制台程序,并通过一个具体的例子解释了如何进行程序调试。接着,作者通过一个加法计算器的实例,演示了如何编写可视化程序。最后,简要提到了VisualBasic6.0 IDE及其在创建可视化窗口应用中的使用。
摘要由CSDN通过智能技术生成

目录

一,Visual Basic

二,控制台程序

三,可视化程序

1,IDE

2,实例——加法计算器


一,Visual Basic

Visual Basic是可视化的Basic,简称VB

VB是第一个可视化编程语言。

二,控制台程序

用visual studio可以创建VB的控制台工程,先填一个Hello world:

Module Module1

    Sub Main(args As String())
        Console.WriteLine("Hello, world!")
    End Sub

End Module

VB的控制台程序员也可以打断点、单步调试。

以atcoder的Contest 229的A - First Grid为例:

Problem Statement

We have a grid with 22 horizontal rows and 22 vertical columns.
Each of the squares is black or white, and there are at least 22 black squares.
The colors of the squares are given to you as strings S_1S1​ and S_2S2​, as follows.

  • If the j-th character of Si​ is #, the square at the i-th row from the top and j-th column from the left is black.
  • If the j-th character of Si​ is ., the square at the i-th row from the top and j-th column from the left is white.

You can travel between two different black squares if and only if they share a side.
Determine whether it is possible to travel from every black square to every black square (directly or indirectly) by only passing black squares.

Constraints

  • Each of S1​ and S2​ is a string with two characters consisting of # and ..
  • S1​ and S2​ have two or more #s in total.

Input

Input is given from Standard Input in the following format:

S1​
S2​

Output

If it is possible to travel from every black square to every black square, print Yes; otherwise, print No.


Sample Input 1 

##
.#

Sample Output 1 

Yes

It is possible to directly travel between the top-left and top-right black squares and between top-right and bottom-right squares.
These two moves enable us to travel from every black square to every black square, so the answer is Yes.


Sample Input 2 

.#
#.

Sample Output 2 

No

It is impossible to travel between the top-right and bottom-left black squares, so the answer is No.

首先用C++水一下:

#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s1,s2;
  cin>>s1>>s2;
  if(s1=="#."&&s2==".#")cout<<"No";
  else if(s2=="#."&&s1==".#")cout<<"No";
  else cout<<"Yes";
  return 0;
}

然后用Visual Basic来写:

Imports System.IO

Module Module1

    Sub Main(args As String())
        Dim s1 As String
        Dim s2 As String
        s1 = Console.ReadLine()
        s2 = Console.ReadLine()
        If s1 = ("#.") And s2 = (".#") Then
            Console.WriteLine("No")
        ElseIf s2 = ("#.") And s1 = (".#") Then
            Console.WriteLine("No")
        Else
            Console.WriteLine("Yes")
        End If

    End Sub

End Module

这个代码可以AC

三,可视化程序

1,IDE

visual studio也可以做VB的可视化程序,但是我没看明白咋用。

我记得高中用的应该也是visual basic 6.0,所以在继续用这个IDE

 资源分享汇总

新建工程会有个默认窗口

左边是常用控件,如DirListBox,直接放一个在窗口里运行就可以访问本地文件,非常方便。

2,实例——加法计算器

首先放控件,3个文本框,1个按钮

 然后双击按钮,自动创建函数Check1_Click,填补函数

Option Explicit

Private Sub Check1_Click()
Text3.Text = CSng(Text1.Text) + CSng(Text2.Text)
End Sub

运行即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值