给每个字符添加一个空格而不用它们创建一个列VBScript

问题描述

我正在尝试制作一个仅向字符添加空格且不使用它们创建列的脚本。这是我尝试的代码

<%

a=Split("Example1,Example2,Example3",",")
for each x in a
    response.write(x & "<br />")
next

%>

问题是我有一个大文本,只有这样才能创建出来(这是正常的输出):

  • “ Example1”
  • “ Example2”
  • “ Example3”

我要写的是这样的: “ E x a m pl e 1 E x a m pl e 2 E x a m pl e 3”

我是在这里编码的新手,所以我没有任何想法。任何帮助表示赞赏。

解决方法

正如Lankymart在评论中提到的那样,您可以遍历字符串的每个字符并添加一个空格。这是执行此操作的简单函数:

import React,{ Component } from "react";
import Popover from "@material-ui/core/Popover";
import Typography from "@material-ui/core/Typography";
import { withStyles } from "@material-ui/core/styles";

const useStyles = (theme) => ({
  root: {
    backgroundColor: "red",height: "30px",},lable: {
    transform: "translate(5px,2px) scale(1)",pointerEvents: "none",width: "100%",height: "100%",padding: "10px",color: "red",popover: {
    pointerEvents: "none",color:"pink"
  },paper: {
    padding: theme.spacing(1),etc:{
    color: "red"
  }
});

class SomeThing extends Component {
  open;
constructor(props){
  super(props)
  this.handlePopoverClose = this.handlePopoverClose.bind(this);
    this.handlePopoverOpen = this.handlePopoverOpen.bind(this);
  this.state={
    anchorEl: null,}
}
componentDidMount(){
  this.open = Boolean(this.state.anchorEl);
}
  handlePopoverOpen = (event) => {
    console.log("triggered!!!",event.currentTarget.innerText);
    this.setState({ anchorEl: event.currentTarget.innerText });
  };

  handlePopoverClose = () => {
    console.log("triggered again!!!",this.props);
    this.setState({ anchorEl: null });
  };
  render() {
    return (
      <div>
        <Typography
          aria-owns={this.open ? "mouse-over-popover" : undefined}
          aria-haspopup="true"
          className={this.props.classes.etc}
          onMouseEnter={this.handlePopoverOpen}
          onMouseLeave={this.handlePopoverClose}
        >
          Hover with a Popover.
        </Typography>
        <Popover
          id="mouse-over-popover"
          className={this.props.classes.popover}
          classes={{
            paper: this.props.classes.paper
          }}
          open={this.open}
          anchorEl={this.state.anchorEl}
          anchorOrigin={{
            vertical: "bottom",horizontal: "left"
          }}
          transformOrigin={{
            vertical: "top",horizontal: "left"
          }}
          onClose={this.handlePopoverClose}
          disableRestoreFocus
        >
          <Typography>I use Popover.</Typography>
        </Popover>
      </div>
    );
  }
}

export default withStyles(useStyles)(SomeThing);

您可以在现有循环中使用此功能:

Function SpaceText(p_sText)
    Dim iCounter
    Dim sSpacedText
    
    sSpacedText = ""
    For iCounter = 1 To Len(p_sText)
        sSpacedText = sSpacedText & Mid(p_sText,iCounter,1)
        If iCounter < Len(p_sText) Then sSpacedText = sSpacedText & " "
    Next

    SpaceText = sSpacedText

End Function

请注意,它不会在最后一个字母后添加多余的空格,因此在连接数组的值时需要考虑到这一点。